10-29-2015 12:48 AM - edited 03-01-2019 09:18 AM
Hi,
I need to rename a file name with four character prefix followed by the original file name.
eg) abcde.txt to xyz_abcde.txt.
I tried with the normal renaming command ren path\abcde.txt xyz_*.txt.
Output I got was xyz_e.txt, the first four character of the orginal file name was replaced by the prefix, this is what I was not expecting.
Could someone help me to solve this issue.
10-29-2015 04:12 AM
Seems like a batch script question. The rename command is behaving as expected.
Have you tried using Tidal variables to hold the values abcde.txt and xyz_ and use them in yoru jobs ?
For example,
ren path\<fromfilename> <prefix><fromfilename>
where fromfilename(="abcde.txt") and prefix(="xyz") are Tidal variables
10-29-2015 06:57 AM
Hi Dinesh,
Triedby the way you suggested
/c ren \\path\<source file.502> <prefix.503>_<source file.502>
<source file.502>=*.txt
<prefix.503>=xyz
But still the renaming is not as expected.
10-29-2015 08:10 AM
Can you try with
<source file.502>="abcde.txt"
<prefix.503>="xyz_"
I suspect the '*' is causing the issue
11-27-2015 02:10 AM
encountered the issue with the following command inside a batch file
for %%f in (File name to be renamed) do copy "%%f" "path\prefix name%%f"
10-29-2015 08:38 AM
Thanks Dinesh, it is working now.
11-02-2015 12:28 PM
or maybe a batch file something like
echo off for %%i in ("abcd*.txt") do (set fname=%%i) & call :rename goto :eof :rename ::Cuts off 1st 4 characters of fname, then appends prefix ren "%fname%" "xyz%fname:~4%" goto :eof
e.g.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide