I need to schedule a bat file that copies files from a folder whose name changes daily and I need to copy those from yesterday's folder. I.e. if today is feb 12, 2010 I need to copy files from folder 20100211 and tomorrow I will need to copy from folder 20100212.

@Johannes. It is not quite as simple. While this functions may parse US date format, they do not work for all formats out there. Example is Croatian date format (d.M.yyyy.). Yes, you could probably compensate for it but this is too much dependency on system and particular locale for me to be satisfied with it. I would use it only as last resort.
–
Josip MedvedFeb 14 '10 at 18:32

As mentioned there, the output of date shows the format as well as the separator so it can parse dates in various formats.
–
JoeyFeb 14 '10 at 21:12

@Johannes. As mentioned there, it does not work in current form with single d/m/y designators. I tried it on my system and it does work when I change it to US format, but it does not work form my default. It can be modified - there is no doubt there - but I see this like last resort only if more advanced shell is not available. For me just having that number of lines in batch is quite scary.
–
Josip MedvedFeb 14 '10 at 21:50

Would it suffice to keep the parent directory of these YYYYMMDD directories synced to another directory? That way, you wouldn't have to worry about the name changes. Robocopy is a great command-line tool for mirroring one directory to another. It became one of the standard commands as of Vista. If you're still using XP, you can get it as part of the Windows Server 2003 Resource Kit Tools. If you don't want everything in the parent directory copied, you can specify files and/or directories to ignore in a robocopy job file.

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.