Batch file to copy and rename the copied file - batch-file

I would like to create a batch file to copy *.EXT files to the destination folder with appended date and time to file name and copy upto maximum 30 files. After 30 files are copied, should delete oldest file. (while copy the 31st file, the 1st file should be deleted, and so on).
Thanks for your support. Have a great day!

Related

How to copy only PDF files last modified today?

I have the below code to copy all PDFs from drive C: to drive D:.
#ECHO OFF
COPY "C:\testing\*.pdf" "D:\testing2\*.pdf"
I only want to copy the latest PDF.
What do I need to copy only the files with last modification date equal today´s data?

Rename all the files in the folder including sub folders

I have a requirement to rename all files in a folder (including subfolders) by adding the last modified time in the original file name.
For Example... filename.txt and last modified time is 01/02/2018 7:10 then the new file should be renamed as filename_20180201_0710_V1.txt
The script should change all the files in the folder and subfolders.
Thanks
Regards,
Gowtham

Create batch file to copy mdb file to another folder and renaming it

I'm trying to create batch file to copy mdb file to another folder then renaming it and run a task scheduler everyday. so everytime the batch runs, the same mdb file will copy and rename. I don't care about the additional characters just copy and rename will do.
folder A (source folder)
test.mdb 06/21/2014
folder B (target folder)
test02.mdb 06/21/2014
test03.mdb 06/22/2014
thanks
copy "c:\folder a\test.mdb" "b:\folder b\test%random%.mdb"
The random number is 0 to 32,000. To do it by dates
Set NewDate=%date:/=%
copy "c:\folder a\test.mdb" "b:\folder b\test%newdate%.mdb"
This will copy and rename a file:
copy "folder A\test.mdb" "folder B\test02.mdb"

Accidentally copied folder and files into a single file

An ms-dos backup batch file has copied all files and subfolders from a single folder into a single file on a usb stick. Is there any way we can extract theses files and folders from the single file that was created?
I believe what you probably did was the equivalent of
copy f1.txt d:\backup\backupfile
copy f2.txt d:\backup\backupfile
copy f3.txt d:\backup\backupfile
which, since backupfile isn't a directory, copied all 3 files, successively, to the file d:\backup\backupfile.
Unfortunately, this means that first f1.txt was copied to that file, then f2.txt, then f3.txt. Since each copy overwrote the file, I think you'll find that the contents of backupfile are equivalent to f3.txt (the last file that was backed up). If you have already deleted f1 and f2.txt, then they're gone.

How to exclude a specific file from being copied using xcopy

I'm new to Windows batch files, but I'm writing a .bat file that just copies a bunch of files from one place to another maintaining the file directory structure. Using xcopy this is simple but I need to exclude some files from being copied. You can use /exclude and create a text file full of strings that you want to be excluded, but this doesn't just exclude files with the exact names in the text file, it excludes all files whose filenames contain any of the strings in the text file.
What this means is, if I want to exclude any files named 123.txt and put this string in my exclusions text file, if there was a file called 1123.txt anywhere in the source folder or any of its subfolders that would also be excluded.
How can I exclude only files with a specific filename from being copied?
Evening Bill.
Can you add a slash before each file name? That should work
EG
instead of
123.txt
blah.txt
use
\123.txt
\blah.txt
Try creating a temporary folder, xcopying all of the files into that folder, deleting the ones you don't want, then xcopying those to the final destination. Finally, delete the temporary folder and its contents with rd xyzzy /q/s

Resources