You can rename files in batch in bulk using, for example:
rename *.docx *.pdf
However, when my docx files have spaces in them, this renames them to new files which only have the first word in their file name. How do I preserve the entire file name?
EDIT: Apparently this is only the case when the file name as a dot in it (but the file has no extension still), for example:
2017. abcdef
Related
I have some directory containing several subdirectories. Each subdirectory contains one .pdf file with some random name. I want to rename all these files with my_new_name.pdf. What is the best way to do it using command prompt?
How would I rename a string in all file types not just one file type like .txt in Windows 10? Like for example if all my file names were named Bear-(number) but there are lots of different file types like .html, .php, .pdf, .css, & more how could I rename them all? I don't want to have to list all the file types in the folder... Your help would be appreciated.
In windows 10, use command prompt by clicking on the windows button and typing in cmd
Switch to the directroy you have your files in - for example if they are in a directory called 'temp' enter cd temp.
Another example - if the files are in a nested folder like c:\temp\test - enter cd c:\temp\test
If they are on another drive, you will need to change to that drive by specifying the drive letter and then a colon... eg 'e:'
rename all files rename Bear-00001.* Bear-00002.*
The * at the end will preserve the file extension while changing the file name itself
hth
I have been tasked with stripping out around 50 thousand .INI files from a windows folder that has 58 thousand files in it the issue is that the files aren't in order and removing these manually would be very time consuming.
The files themselves use number Id's as their naming convention and I managed to get an Excel spreadsheet together with all the ID's I need to remove. My question is, can I put these ID's somewhere like a batch file and get it to remove these if so how?
Thanks in advance.
Here is the simplest script that will work:
cd "C:\directory\location\"
del "*.ini" /s
exit
The first line makes sure its in the directory that all the files are in, the second one deletes all the files in the specified folder and all of its subfolders (the subfolders can keep their .ini files if you remove the /s), and the third line quits the batch file. The third line is not necessary. The first line can be revoked if the batch file (.bat) is in the same folder as all of the .ini files.
I would like to be able to copy all files from various folders and combine them into a single folder using a Windows batch file. That is fairly easy to do for me. But if the file already exists on the destination, I would like it to only override the file if it's newer.
copy c:\pics\ to d:\
Thanks.
You can use xcopy for more options if the source dirs are 2-3-5 (write separate xcopy lines for each). If the dirs are too many, you can use archiver like WinRar (or its command line rar.exe) with #list option where are stored the source dirs. In the batch file call RAR 2 times - first to pack all source files to one archive, then to unrar them in single folder (with E option, not X). Finally, you delete the .rar file. See the extra options to skip older files, omit prompts, etc.
I have a directory called clients. In this directory there are more directories and some files. All the file names start with double underscore as given below. All the files in clients directory or within the directories within clients have file names starting with double underscore.
client1/
client2/
__a.txt
__b.txt
I need to rename all the files to a single underscore. All the files are in github so we use git.
What would be a good tool I should read up on. sed / awk ?
If your (unix?) system has the rename command:
cd client2
rename 's/^__/_/' *