Home » Questions » Computers [ Ask a new question ]

Bat file that copies files from a folder with changing name as YYYYMMDD

Bat file that copies files from a folder with changing name as YYYYMMDD

Can anyone point me in the right direction?

Asked by: Guest | Views: 390
Total answers/comments: 1
Guest [Entry]

"Here is a batch script that will copy files from C:/FromFolder/yyyymmdd to C:/ToFolder (yyyymmdd is yesterday's date).

# Script CopyYesterday.txt
var str yesterday, list, file
set $yesterday = addtime(diff(""-1000000"")) # ""-1000000"" = subtract 1 day, 00 hrs, 00 mins, 00 secs
chex ""8]"" $yesterday > $yesterday
# We now want to copy files from C:/FromFolder/$yesterday to C:/ToFolder.
lf -n ""*"" (""C:/FromFolder/""+$yesterday) ($ftype==""f"") > $list
while ($list <> """")
do
lex ""1"" $list > $file
system -s ""copy /Y"" (""\""""+$file+""\"""") ""C:/ToFolder""
done

Copy and save the script in file C:/Script/CopyYesterday.txt. Then schedule this command to run daily.

""C:/biterScripting/biterScripting.exe"" ""C:/Script/CopyYesterday.txt""

You will need to install biterscripting ( http://www.biterscripting.com ). It is great for flexible file management. The help pages for addtime, lf command etc, are at their site or you can also do ""help addtime"", etc. in biterscripting."