Add to a file
Moderator: DosItHelp
-
- Posts: 1
- Joined: 16 Dec 2010 10:39
Add to a file
How can I add to a file name?
I have a directory called TEST.
Inside TEST there are 200 files (all of different names and extensions).
How can I add “a” in front of each name and still keep the same name and extension. i.e. c:\TEST\hello.txt will become c:\TEST\ahello.txt.
I want to use a batch file.
I have a directory called TEST.
Inside TEST there are 200 files (all of different names and extensions).
How can I add “a” in front of each name and still keep the same name and extension. i.e. c:\TEST\hello.txt will become c:\TEST\ahello.txt.
I want to use a batch file.
Re: Add to a file
i don't think that's possibel but i will see what i can do
Re: Add to a file
I found one code that change the first letter to a
Code: Select all
@echo off
rename "C:\Your\Folder\Destination\*.*" a*.*
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: Add to a file
This should do it:
Code: Select all
for /f "tokens=*" %a in ('dir /b') do rename "%a" "a%a"
Re: Add to a file
Nope ChickenSoupe that doesn't work.
Re: Add to a file
It's designed for command line.
In the batch you must double the %
In the batch you must double the %
Re: Add to a file
The lines below work for me with limited testing. Remove the word ECHO if $$$test.txt gives you the desired results.
Best wishes all.
@echo off
for /f "delims=" %%f in (
'dir /b *.*') do (
set name=%%~nxf
ECHO ren "%%~nxf" "a%%~nxf"
)>>$$$test.txt
set name=
Best wishes all.
@echo off
for /f "delims=" %%f in (
'dir /b *.*') do (
set name=%%~nxf
ECHO ren "%%~nxf" "a%%~nxf"
)>>$$$test.txt
set name=
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: Add to a file
ChickenSoup wrote:This should do it:Code: Select all
for /f "tokens=*" %a in ('dir /b') do rename "%a" "a%a"
Yes, inside a batch file it would be the following:
Code: Select all
for /f "tokens=*" %%a in ('dir /b') do rename "%%a" "a%%a"
Re: Add to a file
good job chicken soup it works