I am trying to write a batch script that can find the files created/modified/newer since yesterday and/or any specific day from today in a particular folder. Then those files need to be copied to different location.
I tried to use the forfiles
command but my XP doesn't have that command.
Any help would be awesome!
Best Answer
You can use Horst Schaeffer's excellent wasfile.exe tool:
for /r c:\particular_folder %i in (*.*) do @wasfile.exe %i created after Today-1 > nul && @copy %i f:\different_location
You can change created and modified per your need:
I think you mean (*.*)? Yes, this tells you what set you are interested in. *.csv would isolate just the csv files.
You might benefit from reading some web sites for background:
http://www.netikka.net/tsneti/http/tsnetihttpprog.php#batch
http://www.netikka.net/tsneti/info/tscmd.php
Google batch tutorial for more sites.
In a batch file, @command means don't echo the command line to the screen. Otherwise, you will see both what you asked for as well as what the result was. The && means 'process what follows if command is successful' and determines this by errorlevel. If I wanted 'was not successful' I would have used ||.
In this case, you read the code as: Is the file newer than my target date, and if yes (&&) copy it to some location. Don't show me any output from my command ">nul"
Ok?