Prashanth_atthaluri
asked on
Renaming extensions of files in DOS
Hi
I am using XP professional.
i have a folder, with following files
c:\Source\STMTPRNT.SPL.Ext racted900- 026-611220 07
STMTPRNT.SPL.Extracted900- 027-411220 07
STMTPRNT.SPL.Extracted900- 028-211220 07
STMTPRNT.SPL.Extracted900- 030-811220 07
STMTPRNT.SPL.Extracted900- 031-611220 07
i want to move them to another folder
c:\Destination\STMTPRNT.SP L.Extracte d900-026-6 1122007.tx t
STMTPRNT.SPL.Extracted900- 027-411220 07.txt
STMTPRNT.SPL.Extracted900- 028-211220 07.txt
STMTPRNT.SPL.Extracted900- 030-811220 07.txt
STMTPRNT.SPL.Extracted900- 031-611220 07.txt
i am using the following command
xcopy c:\source\*.extracted* c:\destination\*.extracted *.txt /s
but in the destination only one file is created as
c:\Destination\STMTPRNT.SP L.txt
Please, help me. I am new to DOS, detailed explanation is highly appriciated.
Thanks
I am using XP professional.
i have a folder, with following files
c:\Source\STMTPRNT.SPL.Ext
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
i want to move them to another folder
c:\Destination\STMTPRNT.SP
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
STMTPRNT.SPL.Extracted900-
i am using the following command
xcopy c:\source\*.extracted* c:\destination\*.extracted
but in the destination only one file is created as
c:\Destination\STMTPRNT.SP
Please, help me. I am new to DOS, detailed explanation is highly appriciated.
Thanks
HI,
MSDOS will only read and create files with the 8.3 file format
xxxxxxxx.xxx (8.3)
For more detail have a look at this article
http://en.wikipedia.org/wiki/8.3_filename
Regards,
TT
MSDOS will only read and create files with the 8.3 file format
xxxxxxxx.xxx (8.3)
For more detail have a look at this article
http://en.wikipedia.org/wiki/8.3_filename
Regards,
TT
ASKER
Hey paul
i tried the command you mentioned, its creating only one file, which means all the previous files are replaced.
Thanks
i tried the command you mentioned, its creating only one file, which means all the previous files are replaced.
Thanks
I would recommend trying something like this instead:
for /f %i in ('dir /a-d /b c:\source\*extracted*) do ('xcopy c:\source\%i c:\destination\%i.txt /s')
Hope this helps!
:o)
Bartender_1
for /f %i in ('dir /a-d /b c:\source\*extracted*) do ('xcopy c:\source\%i c:\destination\%i.txt /s')
Hope this helps!
:o)
Bartender_1
xcopy /s/c/h/d "source"\*.* "destination"\*.*
Sorry, second set of quotes is not necessary, this command from the command line should work:
for /f %i in ('dir /a-d /b c:\source\*extracted*) do (xcopy c:\source\%i c:\destination\%i.txt /s)
If you want to use this command in a batch file it should look like this:
for /f %%i in ('dir /a-d /b c:\source\*extracted*) do (
xcopy c:\source\%i c:\destination\%i.txt /s
)
Hope this helps!
:o)
Bartender_1
for /f %i in ('dir /a-d /b c:\source\*extracted*) do (xcopy c:\source\%i c:\destination\%i.txt /s)
If you want to use this command in a batch file it should look like this:
for /f %%i in ('dir /a-d /b c:\source\*extracted*) do (
xcopy c:\source\%i c:\destination\%i.txt /s
)
Hope this helps!
:o)
Bartender_1
~sighs~ nothing like using copy/paste to replicate errors....
Sorry, try this command from the command line:
for /f %i in ('dir /a-d /b c:\source\*extracted*') do (xcopy c:\source\%i c:\destination\%i.txt /s)
this for a batch file:
for /f %%i in ('dir /a-d /b c:\source\*extracted*') do (
xcopy c:\source\%i c:\destination\%i.txt /s
)
Sorry, try this command from the command line:
for /f %i in ('dir /a-d /b c:\source\*extracted*') do (xcopy c:\source\%i c:\destination\%i.txt /s)
this for a batch file:
for /f %%i in ('dir /a-d /b c:\source\*extracted*') do (
xcopy c:\source\%i c:\destination\%i.txt /s
)
ASKER
hey Bartender_1
I have used
for /f %%i in (dir /a-d /b C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\*extra cted*) do (xcopy C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\%i C:\FDIC\VisionBKP\Data\vis iontxt\%i. txt /s)
i got the following error:
%%i was unexpected at this time.
Thanks
I have used
for /f %%i in (dir /a-d /b C:\FDIC\VisionBKP\Data\ARC
i got the following error:
%%i was unexpected at this time.
Thanks
If this is from the command line, try this:
for /f %i in ('dir /a-d /b C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\*extra cted*') do (xcopy C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\%i C:\FDIC\VisionBKP\Data\vis iontxt\%i. txt /s)
for /f %i in ('dir /a-d /b C:\FDIC\VisionBKP\Data\ARC
If used from the command line, the variable is denoted with a single %, if used in a batch file, it needs a double %%.
Also, please note, that in either case you need to use a single quote around the command 'dir /a-d /b c:\path\*extracted*'
Hope this helps!
:o)
Bartender_1
Also, please note, that in either case you need to use a single quote around the command 'dir /a-d /b c:\path\*extracted*'
Hope this helps!
:o)
Bartender_1
You are better off doing the copy/move part first, and then rename files - that is much easier to accomplish, and faster.
pushd c:\FDIC\VisionBKP\Data
xcopy ARCHIVE_unzipped\*extracte d* visiontxt\
ren visiontxt\*extracted*. *extracted*.txt
popd
Bartender,
There is no use of FOR /F in that case (and the parens around the xcopy are superfluous). It works, but it is cumbersome. A simple
for %i in (c:\FDIC\VisionBKP\Data\AR CHIVE_unzi pped\*extr acted*) do xcopy "%i" "C:\FDIC\VisionBKP\Data\vi siontxt\%~ nxi.txt"
is much better. Further, the /s for xcopy is even wrong - we do not want to go into subfolders.
pushd c:\FDIC\VisionBKP\Data
xcopy ARCHIVE_unzipped\*extracte
ren visiontxt\*extracted*. *extracted*.txt
popd
Bartender,
There is no use of FOR /F in that case (and the parens around the xcopy are superfluous). It works, but it is cumbersome. A simple
for %i in (c:\FDIC\VisionBKP\Data\AR
is much better. Further, the /s for xcopy is even wrong - we do not want to go into subfolders.
Qlemo,
~sheepish grin~ You're right of course. I didn't even bother to check the switches for the xcopy command.
~sheepish grin~ You're right of course. I didn't even bother to check the switches for the xcopy command.
ASKER
Hey Bartender
Sorry for misleading example, there are many subfolders from which i have to copy the files.
when i run this cmd
for /f %i in ('dir /a-d /b C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\*extra cted*') do (xcopy C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\%i C:\FDIC\VisionBKP\Data\vis iontxt\%i. txt /s)
I think there is a problem, i.e when ever there is a space in folder name eg:
C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\vision -200911161 40126 [289]_rebuild\
then the variable is just returning C:\FDIC\VisionBKP\Data\ARC HIVE_unzip ped\vision -200911161 40126
so i am getting, the following error
C:\FDIC\VisionBKP\Data\vis iontxt\STA TEMENTS>re n "c:\FDIC\VisionBKP\Data\vi siontxt\ST ATEMENTS\v ision-2010 1217235906 " "i.txt"
The system cannot find the file specified.
Please, let me know the solution.
Thanks
Sorry for misleading example, there are many subfolders from which i have to copy the files.
when i run this cmd
for /f %i in ('dir /a-d /b C:\FDIC\VisionBKP\Data\ARC
I think there is a problem, i.e when ever there is a space in folder name eg:
C:\FDIC\VisionBKP\Data\ARC
then the variable is just returning C:\FDIC\VisionBKP\Data\ARC
so i am getting, the following error
C:\FDIC\VisionBKP\Data\vis
The system cannot find the file specified.
Please, let me know the solution.
Thanks
Ok,
Just to ensure I have a clear picture here, you have a number of files, in multiple subfolders, some containing spaces in the names, all within the "C:\FDIC\VisionBKP\Data\AR CHIVE_unzi pped" folder, and you want to copy all of the files to a backup location and append the ".txt" to the filenames. Am I correct in assuming you wish to retain the folder structure in the backup location?
Just to ensure I have a clear picture here, you have a number of files, in multiple subfolders, some containing spaces in the names, all within the "C:\FDIC\VisionBKP\Data\AR
ASKER
Yes Sir.
Ok, Are you attempting to do this in a single command you can enter from the command line, or can this be put into a batch file?
I don't know of any way with simple commands to do this all in one go. Qlemo is correct, at this point it is simpler to copy the files over, then do the renaming.
Strictly speaking, you could enter multiple commands on the command line and accomplish this, but that's what a batch file is supposed to be for, to take multiple lines of commands, and execute them in sequence.
I don't know of any way with simple commands to do this all in one go. Qlemo is correct, at this point it is simpler to copy the files over, then do the renaming.
Strictly speaking, you could enter multiple commands on the command line and accomplish this, but that's what a batch file is supposed to be for, to take multiple lines of commands, and execute them in sequence.
ASKER
Please, give me the batchfile.
i tried what 'Qlemo' said. Copied first and tried to rename later. But did not kow how to use 'REN' to rename files in subfolders.
Thanks
i tried what 'Qlemo' said. Copied first and tried to rename later. But did not kow how to use 'REN' to rename files in subfolders.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, in your batch file you'll want this:
@echo off
xcopy "C:\FDIC\VisionBKP\Data\ARCHIVE_unzipped\*extracted*" C:\FDIC\VisionBKP\Data\visiontxt\ /s
for /f "delims=" %%i in ('dir /a-d /b /s C:\FDIC\VisionBKP\Data\visiontxt\') do ren "%i" "%~ni.txt"
Wups. Guess I'm slow.
:o)
Bartender_1
:o)
Bartender_1
Ehem. You forgot to use %% instead of % in your rename command ;-).
You're correct of course.
:o)
Bartender_1
:o)
Bartender_1
@echo off
xcopy "C:\FDIC\VisionBKP\Data\ARCHIVE_unzipped\*extracted*" C:\FDIC\VisionBKP\Data\visiontxt\ /s
for /f "delims=" %%i in ('dir /a-d /b /s C:\FDIC\VisionBKP\Data\visiontxt\') do ren "%%i" "%%~ni.txt"
ASKER
Hey Bartender
when i ran this cmd
for /f "delims=" %i in ('dir /a-d /b /s C:\FDIC\Westbridge\VisionB KP\Data\vi siontxt\St atements') do ren "%i" "%~ni.txt"
i got following error
ren "C:\FDIC\Westbridge\Vision BKP\Data\v isiontxt\S tatements\ vision-201 0121723590 6 [289]\STMTSAVG.spl.Extract ed500-100- 312172010" "STMTSAVG.spl.txt"
A duplicate file name exists, or the file cannot be found.
I think .extracted* part is getting replaced by .txt. Please, look into it.
I appriciate the pain you are taking to help me.
Thanks a lot.
when i ran this cmd
for /f "delims=" %i in ('dir /a-d /b /s C:\FDIC\Westbridge\VisionB
i got following error
ren "C:\FDIC\Westbridge\Vision
A duplicate file name exists, or the file cannot be found.
I think .extracted* part is getting replaced by .txt. Please, look into it.
I appriciate the pain you are taking to help me.
Thanks a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey, Bartender Thanks so much.
Thanks Qlemo
Thanks Qlemo
xcopy c:\source\*.extracted* c:\destination\*.txt /s