batch-rename

Powershell renaming a specific Character

只愿长相守 提交于 2020-01-05 04:17:09
问题 I've been batch renaming .las files in powershell with a simple script: cd "C:\Users\User\desktop\Folder" Dir | Rename-Item -NewName {$_.name-replace "-", "" } Dir | Rename-Item -NewName {$_.name-replace "_", "" } Dir | Rename-Item -NewName {$_.BaseName+ "0.las"} This has been working great, but I need to modify it to account for a different naming convention. The files start out in this format: 123_45-67-890-12W_ 0 and get converted to 123456789012W00.las Occasionally the number after the W

Perl's rename - how to append a counter?

偶尔善良 提交于 2020-01-03 02:33:06
问题 There's a nice renaming utility, which comes with Perl's installation. How one would append a counter in the Perl regexp? This is a relevant question e.g. for a problem of numbering files in the current directory: rename 's/^/<here I'd like to have a number of a file being processed>/g' * For example how would one rename: fileA fileB fileC to 1 - fileA 2 - fileB 3 - fileC Edit : I've added the counter feature ( $c variable) - see here. It works fine - but when I try to specify the counter

Rails: renaming a controller and corresponding model

∥☆過路亽.° 提交于 2019-12-31 01:43:11
问题 Is there an easy way to rename a controller and model in my app and all the instances in the corresponding code? I'm using textmate, would this be as simple as using the replace function and replacing the word Post with Report? 回答1: If you are using textmate, use 'command-shift-f" to look for a string throughout your entire project. 回答2: You need to change the name of the Controller and the associated Model , Views , Helpers , Tests & Routes directories, file names, class names & the names in

Rename files in multiple directories to the name of the directory

久未见 提交于 2019-12-29 04:17:05
问题 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. 回答1: 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.

Batch rename folders

无人久伴 提交于 2019-12-25 12:09:12
问题 I have about 2000 folders all named like this dataul_-_ppfsefs music_-_ppfsefs fun [gghhhses] pictures_-_ppfsefs backup [gghhhses] tempfiles_-_ppfsefs trash_it_-_ppfsefs There are two unwanted portion at the end of the name "_-_ppfsefs" and " [gghhhses]", How to I rename them to look like this dataul music fun pictures backup tempfiles trash_it Edit: I'm on Mac OSX (installed brew, macports). 回答1: The following two commands should do it: for dir in * ; do mv "${dir}" "${dir/_-_ppfsefs/}" ;

how to remove final “dot” from directory name

烈酒焚心 提交于 2019-12-24 13:42:08
问题 A program messed up my directory putting a dot "." on the end of some file and directory names. What is the easiest way to remove them? I have thought of removing the last character but not all the files/dirs have a dot on the end. Also removing all the dots is a problem, this will make the extension useless. What I need is a rename to change name.of.the.file.ext. to name.of.the.file.ext and name.of.the.dir. to name.of.the.dir Thanks! 回答1: Go over the files with the dot at the end, rename

Batch File - Rename files based on parent name and (sub)folder(s) name

…衆ロ難τιáo~ 提交于 2019-12-24 07:18:31
问题 Here is the code: for /r %%a in (*.jpg, *.png, *.bmp, *.exe) do ( for /d %%d in (%CD%) do ( set newname=%%~nd%~x1 ren "%%~a" "!newname!%%~Xa" echo media file in %%~fa renamed to "!newname!%%~Xa" ) ) The main problem is that the files in the subfolders end up with filename as the parent directory name i run the bat file from. Example of what happens: C:\parent\name.jpg renamed to C:\parent\parent.jpg C:\parent\child\name.jpg renamed to C:\parent\child\parent.jpg C:\parent\child1\child2\name

PowerShell Command To Bulk Rename Files Sequentially

天大地大妈咪最大 提交于 2019-12-22 18:43:31
问题 I am trying to make batch file naming easier for my end users. In photographing our locations, we can sometimes have only 1 photo or 500 depending on the size of the location. The code below works beautifully to bulk rename our photos based on how many files are in the directory: $prefix = "[SomePrefix]" $files = Get-ChildItem $id = 1 $files | foreach { Rename-Item -Path $_.fullname -NewName ( $prefix + ((($id++).tostring()).padleft(($files.count.tostring()).length) -replace ' ','0' ) + $_

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-20 07:29:04
问题 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

Bash script for renaming files to consecutive numbers in multiple directories

痴心易碎 提交于 2019-12-20 07:27:47
问题 I have a catalogue structure like this: AD -> AD01 -> DSC123.jpg -> DSC124.jpg -> AD02 -> DSC234.jpg -> DSC1455.jpg -> AD03 ->... -> AD04 ->... ->... AE ->... ... No I would like to run a script that will traverse whole tree and rename each folder files to be a consecutive numbers 01.jpg, 02.jpg... etc. I found something like this to help with consecutive numbers: find -name '*.jpg' | gawk 'BEGIN{ a=1 }{ printf "mv %s %02d.jpg\n", $0, a++ }' | bash but how do I make it run on all the folders