batch-rename

Batch Renaming of Files in a Directory

流过昼夜 提交于 2019-11-26 06:54:48
问题 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\" 回答1: 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

Renaming files in a folder to sequential numbers

柔情痞子 提交于 2019-11-26 05:51:52
问题 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). 回答1: 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

How do I completely rename an Xcode project (i.e. inclusive of folders)?

自闭症网瘾萝莉.ら 提交于 2019-11-26 03:25:46
问题 I have a project named XXX . I want to rename this project to YYY . Note that XXX is an extremely common term (for e.g. \"data\", or simply \"project\"), and thus a simple RegEx search-and-replace is not possible, out of risk of corrupting the project configuration files. My current project directory contains the following items: XXX XXXTests XXX.xcodeproj and I want to rename them to: YYY YYYTests YYY.xcodeproj ... respectively, with the necessary changes being reflected in my project file.

How do I completely rename an Xcode project (i.e. inclusive of folders)?

廉价感情. 提交于 2019-11-26 02:23:49
I have a project named XXX . I want to rename this project to YYY . Note that XXX is an extremely common term (for e.g. "data", or simply "project"), and thus a simple RegEx search-and-replace is not possible, out of risk of corrupting the project configuration files. My current project directory contains the following items: XXX XXXTests XXX.xcodeproj and I want to rename them to: YYY YYYTests YYY.xcodeproj ... respectively, with the necessary changes being reflected in my project file. How can I accomplish this without having to manually create and populate a new project? Edit: It is

Rename multiple files based on pattern in Unix

十年热恋 提交于 2019-11-26 01:24:40
问题 There are multiple files in a directory that begin with prefix fgh , for example: fghfilea fghfileb fghfilec I want to rename all of them to begin with prefix jkl . Is there a single command to do that instead of renaming each file individually? 回答1: There are several ways, but using rename will probably be the easiest. Using one version of rename: rename 's/^fgh/jkl/' fgh* Using another version of rename (same as Judy2K's answer): rename fgh jkl fgh* You should check your platform's man page