batch-rename

How to remove a prefix from multiple files?

余生颓废 提交于 2019-12-01 12:50:01
问题 I downloaded a lot of videos that are named like [site.com] filename.mp4 and I wanted to remove the prefix so that they are named like filename.mp4 . I tried a batch file with the following code: ren "[site.com] *.mp4" "///////////*.mp4" But the result was .com] filename.mp4 and can't rename anything beyond the dot, any ideas? 回答1: @ECHO OFF SETLOCAL SET "sourcedir=U:\sourcedir" FOR /f "tokens=1*delims=]" %%a IN ( 'dir /b /a-d "%sourcedir%\*" ' ) DO IF "%%b" neq "" ( FOR /f "tokens=*" %%h IN

.bat for batch rename to increment numbers in fname

我与影子孤独终老i 提交于 2019-12-01 12:12:27
I have a large folder of .cbr's, and I'm renaming them by issue number to correctly order them. What do I need to include in the ren line to have each file increment the number in the file name via windows command prompt? I'll be doing this frequently so I'll make this a .bat file. For example, where n = initial number and m = final number: n.cbr, (n+1).cbr, ..., (m-1).cbr, m.cbr The .bat thusfar: ren *.cbz *.cbr ren *.cbr <increment numbers n through m>.cbr Alternatively, how do I trim each file name so that only the numbers are left before the extension? (from issue1.cbr to 1.cbr) via either

Shell script to copy and prepend folder name to files from multiple subdirectories

佐手、 提交于 2019-11-30 07:28:57
I have several folders with different images sharing file names, with a folder structure like this: /parent/folder001/img001.jpg /parent/folder001/img002.jpg /parent/folder002/img001.jpg /parent/folder002/img002.jpg /parent/folder003/img001.jpg /parent/folder003/img002.jpg ... and would like to copy/rename these files into a new folder, like this: /newfolder/folder001_img001.jpg /newfolder/folder001_img002.jpg /newfolder/folder002_img001.jpg /newfolder/folder002_img002.jpg /newfolder/folder003_img001.jpg /newfolder/folder003_img002.jpg ... (It's probably better if newfolder isn't a subfolder

Bash rename extension recursive

て烟熏妆下的殇ゞ 提交于 2019-11-30 05:03:12
I know there are a lot of things like this around, but either they don't work recursively or they are huge. This is what I got: find . -name "*.so" -exec mv {} `echo {} | sed s/.so/.dylib/` \; When I just run the find part it gives me a list of files. When I run the sed part it replaces any .so with .dylib. When I run them together they don't work. I replaced mv with echo to see what happened: ./AI/Interfaces/C/0.1/libAIInterface.so ./AI/Interfaces/C/0.1/libAIInterface.so Nothing is replaced at all! What is wrong? aps2012 This will do everything correctly : find -L . -type f -name "*.so"

dos command to sperate file name and extension into variables

拥有回忆 提交于 2019-11-30 00:49:27
I need to copy a file x.dtsx from location a to location b. If x.dtsx already exists in b then I need to rename x.dtsx to x_Standby.dtsx Then, after renaming copy x.dtsx to b My current code looks like this: if exists %1 rename %1 %(should be 1_standy.extension) xcopy %1 %2 If you use the Command Processor Extensions (which is default on Windows 2000 and later) then you can use the following optional syntax: %~1 - expands %1 removing any surrounding quotes (") %~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter only %~p1 - expands %1 to a path only %~n1 -

Shell script to copy and prepend folder name to files from multiple subdirectories

白昼怎懂夜的黑 提交于 2019-11-29 09:40:34
问题 I have several folders with different images sharing file names, with a folder structure like this: /parent/folder001/img001.jpg /parent/folder001/img002.jpg /parent/folder002/img001.jpg /parent/folder002/img002.jpg /parent/folder003/img001.jpg /parent/folder003/img002.jpg ... and would like to copy/rename these files into a new folder, like this: /newfolder/folder001_img001.jpg /newfolder/folder001_img002.jpg /newfolder/folder002_img001.jpg /newfolder/folder002_img002.jpg /newfolder

Bash rename extension recursive

本秂侑毒 提交于 2019-11-29 02:49:01
问题 I know there are a lot of things like this around, but either they don't work recursively or they are huge. This is what I got: find . -name "*.so" -exec mv {} `echo {} | sed s/.so/.dylib/` \; When I just run the find part it gives me a list of files. When I run the sed part it replaces any .so with .dylib. When I run them together they don't work. I replaced mv with echo to see what happened: ./AI/Interfaces/C/0.1/libAIInterface.so ./AI/Interfaces/C/0.1/libAIInterface.so Nothing is replaced

Rename files in multiple directories to the name of the directory

…衆ロ難τιáo~ 提交于 2019-11-28 21:27:54
I have something like this: v_1/file.txt v_2/file.txt v_3/file.txt ... and I want to rename those files to something like this: v_1.txt v_2.txt v_3.txt ... in the same directory. I guess I can use rename but I can't figure out how to use it with folder and file renaming at the same time. Csq The result can be achieved with a bash for loop and mv : for subdir in *; do mv $subdir/file.txt $subdir.txt; done; Note that the solution above will not work if the directory name contains spaces. Related link . Another solution based on comments (that works for directories having spaces in the name as

How can I batch rename files using the Terminal?

我们两清 提交于 2019-11-28 15:55:16
问题 I have a set of files, all of them nnn.MP4.mov . How could I rename them so that it is just nnn.mov ? 回答1: First, do a dry run (will not actually rename any files) with the following: for file in *.mov do echo mv "$file" "${file/MP4./}" done If it all looks fine, remove the echo from the third line to actually rename the files. 回答2: I just successfully used Automator (first time I've bothered), and it works really well. I saved the automation as a Service. It took about 10 seconds to make

Rename files to md5 sum + extension (BASH)

那年仲夏 提交于 2019-11-28 10:19:42
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 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' -> `d41d8cd98f00b204e9800998ecf8427e.a' `file.b' -> `d41d8cd98f00b204e9800998ecf8427e.b' `file.c' ->