So I have a program generating txt files sequencially. I need to rename these files once another process runs, so that the process doesn't grab the same file more than once. If I have a file generating A1####.txt, Is it possible to rename these files using a wildcard bat script?
I tried something like:
ren "C:\Folders\AH*.txt" "C:\Folders\AH*.archive"
but get an invalid syntax... any ideas?
Renaming Unknown files
Moderator: DosItHelp
Re: Renaming Unknown files
Code: Select all
@echo off
pushd "C:\Folders"
FOR %%G IN (AH*.txt) do ren "%%~G" "%%~nG.archive"
popd
Re: Renaming Unknown files
%%G was unexpected at this time.
When I run what you gave me... is there something else I need to do prior to that command to identify the %%G parameter?
can you explain what the pushd and pops commands are doing?
When I run what you gave me... is there something else I need to do prior to that command to identify the %%G parameter?
can you explain what the pushd and pops commands are doing?
Re: Renaming Unknown files
The code I gave you is supposed to be run from a batch file and not the CMD prompt.
The PUSHD command sets the working directory to where your files are located.
The POPD command resets the working directory back to where the original working directory was.
The PUSHD command sets the working directory to where your files are located.
The POPD command resets the working directory back to where the original working directory was.