batch-rename

Linux rename files based on another file in the directory?

 ̄綄美尐妖づ 提交于 2019-12-03 12:19:07
I've got about 750 directories that contain two files each: long_somewhat_random_filename.jpg thumb.jpg What I'd like to do is use find or something similar to rename thumb.jpg to long_somewhat_random_filename_thumb.jpg . My brain's kinda fuzzy at the moment. I could do it with a perl script, but if there's a somewhat easy way to do it in bash, that's easier. Give the script below a shot. Right now the echo makes it benign so you can try before you buy so to speak. If you like what you see, remove the echo and run the script again to actually make the changes. #!/bin/bash while read file; do

Batch script to invert the order of a date in file names

强颜欢笑 提交于 2019-12-02 19:35:50
问题 I wanted to use a batch script to rename a bunch of files which are using the following name scheme: File 2-9.pdf File 3-9.pdf File 4-9.pdf [...] I want to invert the numbers so that they will become... File 9-2.pdf File 9-3.pdf File 9-4.pdf [...] Normally I would search for the repeating string and replace it, but in this case the string changes with each file, so I don't know how to go about it. Any ideas? Thank you for reading. EDIT: I am on Windows, I am seeking to create a .bat file.

How to batch rename 40000 files on a folder with number count

﹥>﹥吖頭↗ 提交于 2019-12-02 15:21:56
问题 I need to batch rename 40000 files on a folder with a number count in the end like this:. something.jpg to something_00001.jpg. I'd like to work with the rename command, but anything that works will do. Any Help? Thanks! 回答1: These are powerful commands that will make lots of changes very rapidly - please test on a copy of a small subset of your data. Method 1 - Using "rename" (Perl tool) This should work with rename which you can install on macOS with: brew install rename The command would

Batch script to invert the order of a date in file names

徘徊边缘 提交于 2019-12-02 11:52:29
I wanted to use a batch script to rename a bunch of files which are using the following name scheme: File 2-9.pdf File 3-9.pdf File 4-9.pdf [...] I want to invert the numbers so that they will become... File 9-2.pdf File 9-3.pdf File 9-4.pdf [...] Normally I would search for the repeating string and replace it, but in this case the string changes with each file, so I don't know how to go about it. Any ideas? Thank you for reading. EDIT: I am on Windows, I am seeking to create a .bat file. Something like For %%# in ("file-path") Do ( Set "File=%%~nx#" Ren "%%#" "!File:%Pattern%=%Replace%!" )

Search for a list of words in a file, then find those words on another replacing the whole line with Class=ShipDummy,replacing the 2 lines below it

瘦欲@ 提交于 2019-12-02 10:35:39
I'd like to search for a list of words from an external list (simple each word on a line) which we'll call "List.txt", and search for them in a file (C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR*.clg) (matching the whole word, even if it's inside another, and matching case) , then if they are there find those words on another file(Campaign_SCR.mis.tmp) (matching the whole word even if its inside another, matching case) replacing the whole line in (Campaign_SCR.mis.tmp) with Name=ShipDummy ONLY if the line starts with "Name=". After that the two lines below that in that same file would

How to rename a file according his folder name via batch script

穿精又带淫゛_ 提交于 2019-12-02 03:17:15
问题 I have this part of batch script which is doing following: -There is a main folder, in the main folder are two files (movie & subtitle file) and one Sub-folder called 'Subtitles' -This script takes the name of the movie file and renames with it the subtitle file + moves the subtitle file into the 'Subtitles' sub-folder and then renames the main folder. So at the end we have one movie name, which is used on the subtitle file and on the main folder as well. @echo off setlocal

How to rename the files in the path with the new names from the .txt file in batch?

笑着哭i 提交于 2019-12-02 01:34:54
问题 I have two .txt files. The first one contains the list of pathes to the CD-Images: C:\Users\N\Desktop\LOG_Dateien_CD_Imaging\BFU_KONGRESS_9.ISO C:\Users\N\Desktop\LOG_Dateien_CD_Imaging\NDC2005.ISO The second one contains the new names for this files 490628001 684654326 So the file BFU_KONGRESS_9.ISO in the directory (not in the .txt file!) should be renamed to 490628001.ISO and NDC2005.ISO to 684654326.ISO . The renaming should go line per line 回答1: you need a way to read two files in

Batch remove substring from filename with special characters in BASH

本小妞迷上赌 提交于 2019-12-02 00:53:19
问题 I have a list of files in my directory: opencv_calib3d.so2410.so opencv_contrib.so2410.so opencv_core.so2410.so opencv_features2d.so2410.so opencv_flann.so2410.so opencv_highgui.so2410.so opencv_imgproc.so2410.so opencv_legacy.so2410.so opencv_ml.so2410.so opencv_objdetect.so2410.so opencv_ocl.so2410.so opencv_photo.so2410.so They're the product of a series of mistakes made with batch renames, and now I can't figure out how to remove the middle ".so" from each of them. For example: opencv_ocl

How to rename a file according his folder name via batch script

为君一笑 提交于 2019-12-01 23:26:21
I have this part of batch script which is doing following: -There is a main folder, in the main folder are two files (movie & subtitle file) and one Sub-folder called 'Subtitles' -This script takes the name of the movie file and renames with it the subtitle file + moves the subtitle file into the 'Subtitles' sub-folder and then renames the main folder. So at the end we have one movie name, which is used on the subtitle file and on the main folder as well. @echo off setlocal EnableDelayedExpansion cd /D "%~DP0" echo BASE FOLDER: %cd% set n=0 for /D %%a in (*) do ( set /A n+=1 cd "%%a" echo ====

How to remove a prefix from multiple files?

断了今生、忘了曾经 提交于 2019-12-01 14:21:25
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? @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 ("%%b") DO ECHO(REN "%sourcedir%\%%a]%%b" "%%h" ) GOTO :EOF You would need to change the setting of