Computing.Net > Forums > Programming > copy file with batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copy file with batch

Reply to Message Icon

Name: Shilee
Date: June 18, 2008 at 21:15:24 Pacific
OS: win xp
CPU/Ram: 3.2/512
Product: dell
Comment:

I have somes files are updated everyday and named like "1706...", "1806..." (name same as the day file was created). So i wanna create a bat file to help me auto search for newest files then upload them to my ftp server. Any1 can help?



Sponsored Link
Ads by Google

Response Number 1
Name: Shilee
Date: June 18, 2008 at 21:26:12 Pacific
Reply:

btw,i need those files are copied to fpt server at same time everyday, any idea?


0

Response Number 2
Name: Mechanix2Go
Date: June 18, 2008 at 23:02:44 Pacific
Reply:

"search for newest files "

How many?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: Shilee
Date: June 18, 2008 at 23:20:11 Pacific
Reply:

about 9-10 files


0

Response Number 4
Name: Mechanix2Go
Date: June 19, 2008 at 08:12:36 Pacific
Reply:

This will copy the 9 newest to another directory, from where you can ftp them.

::=====================
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d') do (
set /a N+=1
if !N! gtr 9 goto :eof
copy %%a d:\outgoing
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: Shilee
Date: June 19, 2008 at 18:50:02 Pacific
Reply:

ty Mechanix2Go
but when i mean "newest files", i mean all files were updated same day, i.e: 17068679.CSV,17068678.CSV,17068668.CSV... and i dont know exactly how many files. So i think ur script doesnt work this way right?


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: June 20, 2008 at 06:11:50 Pacific
Reply:

If they all have the same date & time, no it won't work.

If, for these 3 example files:

17068679.CSV,17068678.CSV,17068668.CSV

the 17068 bit is a date and the 679 etc are sequentil numbers, then try this:

::===================
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-n *.csv') do (
set /a N+=1
if !N! gtr 9 goto :eof
copy %%a d:\outgoing
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 7
Name: Shilee
Date: June 23, 2008 at 20:54:27 Pacific
Reply:

ty Mechanic2Go
ur script works fine but like i said b4, I dont know exactly how many "newest files". In ur script it always copies 9 files, so if somedays it has more or less than 9, it will be problem.


0

Response Number 8
Name: Mechanix2Go
Date: June 24, 2008 at 02:42:54 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

set /p H=howmany ?

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-n *.csv') do (
set /a N+=1
if !N! gtr !H! goto :eof
copy %%a d:\outgoing
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 9
Name: Shilee
Date: June 24, 2008 at 02:48:46 Pacific
Reply:

ty Mechanix2Go
so I have to edit file batch everyday? No solution about auto check how many newest files then upload them?


0

Response Number 10
Name: Mechanix2Go
Date: June 24, 2008 at 06:07:06 Pacific
Reply:

Well you either use a fixed number of files or you change it on each run.

Can't think of a third option.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 11
Name: Shilee
Date: June 24, 2008 at 19:19:56 Pacific
Reply:

so it turns out I need the script that can count how many the lastest files in the folder.
any idea?


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: copy file with batch

Copy files with batch www.computing.net/answers/programming/copy-files-with-batch/17443.html

copy files only with a particular name www.computing.net/answers/programming/copy-files-only-with-a-particular-name/19939.html

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html