1.

Solve : Batch to copy latest file??

Answer»

I have a folder of audio files from which I NEED to copy the latest file to ANOTHER drive. That is, a folder on my Z: drive contains audio59.wav, audio60.wav and audio61.wav. I need a batch file that will copy Z:\audio61.wav to C:\audio.wav.

Here's my rudimentary ATTEMPT:

dir /b /O:-D Z:\ > C:\temp1.txt
findstr /c:audio c:\temp1.txt > c:\temp2.txt
type c:\copy.txt c:\temp2.txt > c:\temp3.txt
findstr /c:copy C:\temp3.txt > C:\temp4.txt
type c:\temp4.txt c:\audio_destination_text.txt > c:\temp5.txt
type c:\temp5.txt c:\audio.cmd
audio.cmd

Where:
copy.txt reads "copy z:\"
audio_destination_text.txt reads "c:\audio.wav"

Problem is, the findstr command adds a carriage return so I get this on two separate lines:
copy Z:\audio61.wav
C:\audio.wav

Any thoughts?Quote

I need a batch file that will copy Z:\audio61.wav to C:\audio.wav

I confined the RESPONSE to just this part of your batch file.

Code: [Select]@echo off
for /f "TOKENS=* delims=" %%i in ('dir /o:-d /a:-d /b z:\') do (
copy z:\%%i c:\audio.wav
goto skip
)
:skip

8-)

PS. When did FINDSTR start inserting carriage returns into strings? :-?That's great! Thank you very much for the help.

Question: Can you explain what the "delims" the "tokens" and the "%%i" do?

Thanks again!For a truly nightmare description of the FOR statement, type: FOR /? at your command prompt.

You may have overlooked my question to you: When did FINDSTR start inserting carriage returns into strings?

8-)


Discussion

No Comment Found