3

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

2 Answers 2

2

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)"
Sign up to request clarification or add additional context in comments.

1 Comment

Select your code area, then press {} (on top of edit window) to auto-indent by 4 spaces which formats & highlights your code.
0
@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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.