batch-rename

Batch rename sequential files by padding with zeroes

自古美人都是妖i 提交于 2019-11-28 05:19:44
I have a bunch of files named like so: output_1.png output_2.png ... output_10.png ... output_120.png What is the easiest way of renaming those to match a convention, e.g. with maximum four decimals, so that the files are named: output_0001.png output_0002.png ... output_0010.png output_0120.png This should be easy in Unix/Linux/BSD, although I also have access to Windows. Any language is fine, but I'm interested in some really neat one-liners (if there are any?). DTing Python import os path = '/path/to/files/' for filename in os.listdir(path): prefix, num = filename[:-4].split('_') num = num

How do I rename files in sub directories?

痴心易碎 提交于 2019-11-27 17:42:24
Is there any way of batch renaming files in sub directories? For example: Rename *.html to *.htm in a folder which has directories and sub directories. Anonymous Windows command prompt: (If inside a batch file, change %x to %%x) for /r %x in (*.html) do ren "%x" *.htm This also works for renaming the middle of the files for /r %x in (website*.html) do ren "%x" site*.htm For windows, this is the best tool I've found: http://www.1-4a.com/rename/ It can do anything AND has the kitchen sink with it. For Linux, you have a plethora of scripting languages and shells to help you, like the previous

recursive renaming file names + folder names with a batch file

六月ゝ 毕业季﹏ 提交于 2019-11-27 14:33:27
I like to create a batch file (winxp cmd) that recursively goes through a chose folder and sub folders and renames there files+folders with the following rules: from all file + folder names, all uppercase+lowercase "V" and "W" letters need to be replaced with letters "Y" and "Z". e.g. 11V0W must become 11Y0Z. I believe its possible with FOR /R but how? I think there needs to be a subroutine to be called that checks each letter one by one in addition to basic recursion with FOR /R. The following batch does this for the file names at least. Directories are a bit trickier (at least I couldn't

Rename multiple files in a folder, add a prefix (Windows)

纵然是瞬间 提交于 2019-11-27 09:07:13
问题 I'd like to batch rename files in a folder, prefixing the folder's name into the new names. i.e. files in C:\house chores\ will all be renamed house chores - $old_name . 回答1: Option 1: Using Windows PowerShell Open the windows menu. Type: "PowerShell" and open the 'Windows PowerShell' command window. Goto folder with desired files: e.g. cd "C:\house chores" Notice: address must incorporate quotes "" if there are spaces involved. You can use 'dir' to see all the files in the folder. Using '|'

Rename files to md5 sum + extension (BASH)

梦想与她 提交于 2019-11-27 03:40:52
问题 I need some help with a bash script. Script needs to rename all files in a directory to its md5 sum + extension. I have found the bash script below, but it needs to be changed so that it will add the extension. md5sum * | sed 's/^\(\w*\)\s*\(.*\)/\2 \1/' | while read LINE; do mv $LINE; done 回答1: This might work for you: # mkdir temp && cd temp && touch file.{a..e} # ls file.a file.b file.c file.d file.e # md5sum * | sed -e 's/\([^ ]*\) \(.*\(\..*\)\)$/mv -v \2 \1\3/' | sh `file.a' ->

Batch rename sequential files by padding with zeroes

三世轮回 提交于 2019-11-27 00:43:42
问题 I have a bunch of files named like so: output_1.png output_2.png ... output_10.png ... output_120.png What is the easiest way of renaming those to match a convention, e.g. with maximum four decimals, so that the files are named: output_0001.png output_0002.png ... output_0010.png output_0120.png This should be easy in Unix/Linux/BSD, although I also have access to Windows. Any language is fine, but I'm interested in some really neat one-liners (if there are any?). 回答1: Python import os path =

recursive renaming file names + folder names with a batch file

依然范特西╮ 提交于 2019-11-26 22:24:13
问题 I like to create a batch file (winxp cmd) that recursively goes through a chose folder and sub folders and renames there files+folders with the following rules: from all file + folder names, all uppercase+lowercase "V" and "W" letters need to be replaced with letters "Y" and "Z". e.g. 11V0W must become 11Y0Z. I believe its possible with FOR /R but how? I think there needs to be a subroutine to be called that checks each letter one by one in addition to basic recursion with FOR /R. 回答1: The

Renaming multiples files with a bash loop

大兔子大兔子 提交于 2019-11-26 19:44:45
问题 I need to rename 45 files, and I don't want to do it one by one. These are the file names: chr10.fasta chr13_random.fasta chr17.fasta chr1.fasta chr22_random.fasta chr4_random.fasta chr7_random.fasta chrX.fasta chr10_random.fasta chr14.fasta chr17_random.fasta chr1_random.fasta chr2.fasta chr5.fasta chr8.fasta chrX_random.fasta chr11.fasta chr15.fasta chr18.fasta chr20.fasta chr2_random.fasta chr5_random.fasta chr8_random.fasta chrY.fasta chr11_random.fasta chr15_random.fasta chr18_random

Batch Renaming of Files in a Directory

混江龙づ霸主 提交于 2019-11-26 18:09:46
Is there an easy way to rename a group of files already contained in a directory, using Python? Example: I have a directory full of *.doc files and I want to rename them in a consistent way. X.doc -> "new(X).doc" Y.doc -> "new(Y).doc" Such renaming is quite easy, for example with os and glob modules: import glob, os def rename(dir, pattern, titlePattern): for pathAndFilename in glob.iglob(os.path.join(dir, pattern)): title, ext = os.path.splitext(os.path.basename(pathAndFilename)) os.rename(pathAndFilename, os.path.join(dir, titlePattern % title + ext)) You could then use it in your example

Renaming files in a folder to sequential numbers

江枫思渺然 提交于 2019-11-26 12:35:10
I want to rename the files in a directory to sequential numbers. Based on creation date of the files. For Example sadf.jpg to 0001.jpg , wrjr3.jpg to 0002.jpg and so on, the number of leading zeroes depending on the total amount of files (no need for extra zeroes if not needed). Try to use a loop, let , and printf for the padding: a=1 for i in *.jpg; do new=$(printf "%04d.jpg" "$a") #04 pad to length of 4 mv -i -- "$i" "$new" let a=a+1 done using the -i flag prevents automatically overwriting existing files. Beauty in one line: ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done You