Ever since the earliest DOS versions the
RENAME and its "twin" (or alias?)
REN have been around to allow us to change file names:
REN or RENAME Renames a file or files. RENAME [drive:][path]filename1 filename2. REN [drive:][path]filename1 filename2. Note that you cannot specify a new drive or path for your destination file.
You can even use wildcards in
filename2) to rename, say, all your (very) old MS-DOS (ASCII) help files from *.doc to *.txt:
REN *.doc *.txt
If I remember correctly, in the old MS-DOS days, it was possible to append characters to the file name using the command:
REN *.txt *1.txt
Try that in Windows (XP) and you'll get
The proper way to do this in NT is:
FOR %%A IN (*.txt) DO REN "%%~fA" "%%~nA1.*"
"%%~fA" resolves to the (doublequoted) fully qualified path, and
%%~nA1 to the original file name only, with a
1 appended, and
.* to leave the extension unaltered.
Justin taught me an undocumented
REN feature to chop off everything from a file name after the last occurrence of a specified character:
REN testfile.txt *s
REN testfile.txt *t
will not change the name at all (remember: the last occurrence...?).
REN testfile.txt *st
Does that mean chop off everything after the last occurrence of
st? No it doesn't:
REN testfile.txt *sa
tesa, so it seems to mean chop off everything after the last
s and then append an
REN testfile.txt *a
You can rename folders with the
MOVE d:\path\folder1 folder2
folder2 is a folder name only (not a fully qualified path).
folder2 does not exist, neither in
d:\path nor in the current folder, or the previous command will really move
folder2 a subfolder of
MOVE can be used to rename and move files all in one go:
MOVE d:\path1\oldfilename1 e:\path2\newfilename2
|page last uploaded: 2015-08-24, 21:09|