Reputation: 41
I am absolutely brand new to any kind of development but need a batch job to copy a file from one folder to another. The problem is that the source folder is dynamically named. The folder name will contain the current date and a suffix number (eg. "TestRun_20141106_13") - so I will never be able to determine the 'latest' version of the folder before running the batch / copy job.
Can anyone help please? I know this will be easy for someone but as I said, I am a complete noob!!
Thanks in advance. Jamie
Upvotes: 3
Views: 4843
Reputation: 89
Yes, I havent been doing .bat for that long either, but i think i can help!
Here is a code for the movement of the file!
Dealing wiwth dynamically named folder...
@echo off
set /p txtfile=Filename without Path assumes c:\:
echo.%txtfile%
copy %txtfile% z:\testing\dealer.txt
echo Come back to this window when Agent is done with process. The copy file will be deleted.
@pause
copy %txtfile% c:\somefolder\namedsuccess\%txtfile%
del z:\testing\dealer.txt
exit
You will have to place your own variables in there my friend!
For moving of the files! Easy part!
move /-y "Folder Path that files are in*(Any specific keyword?)*" "(Dest. folder)"
Upvotes: 2
Reputation: 337
@ECHO OFF
FOR /F "TOKENS=*" %%A IN ('DIR "C:\Example" /s /b /a:d') DO SET CurrentDir=%%A
@ECHO.%CurrentDir%
Replace "C:\Example" with the Path your Folders are in, save it to a File (.bat/.cmd) and execute.
The last step - Echo will return the most bottom foldername.
Upvotes: 0