DOS rename files with mask - dos

Old school problem in DOS...
I have a bunch of files
Canada ABCD.txt
USA ABCD.txt
etc
I need to replace ABCD with Ridvan.
Possible?

ren *ABCD.txt *Ridvan.txt
I've just tested this and it works for me. If it doesn't work for you, you'll need to give more info about your specific file names.

Related

Command prompt batch renaming results in syntax error

I need to rename 80k files in multiple folders & subfolders in the same directory. I have been trying to use ren but have been unsuccessful; I get an incorrect syntax error.
My old name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\document_# (x.y.z)-test~.pdf
and my new name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\system, a old name~ ` to # system b document (xyz)-test.pdf
I have the existing directory print in one column of Excel and in the next column what I want the directory print to be.
I'm not sure if I'm starting my ren command at the right hierarchy of my directory, or if I need quotation marks to keep the spaces and symbols in my new name.
I have tried improvising and testing on my own without success and I cannot find an article online on point.
Try FAR (find and replace) - it a free utility that works well.
http://findandreplace.sourceforge.net/

rename files with changing pattern

i want to rename different files in bash with pattern and found this option:
rename 's/.2007/(2007)/g' *.*
with this pattern I can rename every file with ".2007" in name to "(2007)"
--> this is exactly what i want to do.
Next step:
i want to automate this, because i have files with 1995 - 2017. It is a possibility to do:
rename 's/.2007/(2007)/g' *.*
rename 's/.2008/(2008)/g' *.*
rename 's/.2009/(2009)/g' *.*
etc.
but actually, is there another solution?
my files are named like (they are not the same length...):
FILENAME.ANOTHERFILENAME.2007.jpg
FILENAME.2007.jpg
FILENAME.ANOTHERFILENAME.SOMETIMESONEMORE.2007.jpg
With Perl‘s rename:
rename -n 's/.([1-2][0-9]{3})/($1)/' *.*
This renames all files with 1000 to 2999. If everything looks fine remove -n.
For the use-cases where it's not so much about automation but rather about batch processing of a set of files, I find renameutils and its qmv ("quick move") very useful: it enables you to edit the target filenames in a text editor which may be easier/faster than designing regex's for some.
https://www.nongnu.org/renameutils/ (it's in *buntu repos)
But for applications that need to run w/o human intervention, rename is certainly more suitable.

I want to change names Folders

i have Folders I want something to change the Folders names
nameFolders
nameFolders
nameFolders
nameFolders
i want to change the names of Folders to the serial numbers
1nameFolders
2nameFolders
3nameFolders
4nameFolders
Welcome to stackoverflow, please read: How to create a Minimal, Complete, and Verifiable example.
There is no explicit command for renaming files, however mv can be used to acomplish same goal, you could write mv file1 file1_renamed and rename file1 into file1_renamed.

Change several windows folder names at once

I have to rename several folders. The old folders were randomly named, and the new names allow for a consistent naming protocol. i have reconciled the existing folders with the list of new names, but there are hundreds of folders to rename and to do it manually will take forever.
the old name and new name are generally very different. for example:
old: john l,smth new: smith_john_04082013
so what i would like to do is place a list of the old names in one part of a program and the list of new names in another part, and then loop down the list of folders renaming them until the last one is done.
for example
john l,smth (to) smith_john_04082013
mary-jones 42nd street (to) jones_mary_03122013
wil-h-davis (to) davis_william_02122012
etc
i know how to use the rename command in dos, but all that 'seems' to do is just change the name of of one directory, ie rename "john l,smth" "smith_john_04082013"
i tried doing something like:
rename "john l,smth" "smith_john_04082013"; "mary-jones 42nd street" "jones_mary_03122013"; "wil-h-davis" "davis_william_02122012"
the concept being maybe using a separator was the trick to a multiple rename, but that didn't work either.
if anyone knows how to do this that would be very helpful.
TIA
Just create a batch file (plain text file with a .bat extension, like rename_folders.bat), and list each operation as a single line:
ren "john l,smth" "smith_john_04082013"
ren "mary-jones 42nd street" "jones_mary_03122013"
ren "wil-h-davis" "davis_william_02122012"
(ren is the short name for rename, which saves a little typing.)
Once you have all the lines in the file, save it in the folder where you want it to run, open a command prompt in that folder, and just run the batch file (the .bat extension is optional when you run it, as it's one of the known executable file extensions):
C:\YourBaseFolder>rename_folders
or
C:\YourBaseFolder>rename_folders.bat

How to write a single Folder name with all the files in it in a text file in DOS?

Suppose i have a folder structure which has a path like this..
C:\Fold1\Fold2\Fold3\Sample.xls
I want to display the File name i.e Sample.xls in a separate text file along with the Last folder name. That is Fold3
Output in Text file should be like this..
Fold 3
Sample.xls
Please need the code ASAP...
I would do a pure Dir /B in a temp file and then use some awk or grep solution to extract the part I need with regular expressions.
There are many free tools to allow this (GNU for Windows).

Resources