batch-rename

Is there a way to rename directories recursively without using sed or rename?

北慕城南 提交于 2019-12-12 18:55:29
问题 I am trying to rename a few directories that contain "Fever" to contain "Malaria" instead. The instruction is to do it without sed or rename. So far, my errors include mostly lines like mv: cannot stat ‘retest\nretest/Section-01\nretest/Section-02\nretest/Section-03\nretest/Section-04’: No such file or directory . The best my code have done is rename directories in the first level. Here's my directory structure: Fever-A/Malaria-A-A Fever-B/Fever-B-A Fever-B/Fever-B-B Fever-C/Malaria-A Fever-C

How to rename all files over SSH

别来无恙 提交于 2019-12-12 18:28:26
问题 I am trying to rename all files in a remote directory over SSH or SFTP. The rename should convert the file into a date extension, for example .txt into .txt.2016-05-25. I have the following command to loop each .txt file and try to rename, but am getting an error: ssh $user@$server "for FILENAME in $srcFolder/*.txt; do mv $FILENAME $FILENAME.$DATE; done" The error I am getting is: mv: missing destination file operand after `.20160525_1336' I have also tried this over SFTP with no such luck.

Rename script with [Errno2] No such file or directory

ぐ巨炮叔叔 提交于 2019-12-12 06:13:51
问题 I have a folder with over 40 thousand images on an external drive, to use as a sequence for a timelapse. Before using ffmpeg though, I need to add trailing zeros to all the files. My attempt at a solution is shown below: import os path = '/Volumes/Arquivo\ \(carlosbgois@gmail.com\)/stadium_billiard/video/' for filename in os.listdir(path): num = filename[:-4] num = num.zfill(4) new_filename = num + ".png" os.rename(os.path.join(path, filename), os.path.join(path, new_filename)) When running,

Windows Batch File: Output filename without extension

*爱你&永不变心* 提交于 2019-12-11 19:34:54
问题 I have a windows batch file which takes a file, runs it through a compiler to minify the file, then spits it back out. My question is, how can I rename the file like so: I want it to go from script.js to script.min.js I am using the below script: @ECHO OFF ECHO. FOR %%c in (C:\source\*.*) DO java -jar ./Compiler/compiler.jar %%c --js_output_file %%c.min.js ECHO. PAUSE CLS EXIT When I use the script, it outputs the file with a filename of script.js.min.js so I was hoping that I could just cut

Merge 2 text files to one in every subfolder and save them in the same Folder as Date and File named csv file.

▼魔方 西西 提交于 2019-12-11 18:34:12
问题 I wanted to merge in every Folder 2 existing txt files into one and save it in the same Folder as .csv. The Name of new File have to be Date and Time. for /r C:\Users\Juan\Desktop\Konturograph\ %%G in (*.txt) do ( xcopy "%%G" "G%% %date% %time:~0,2%-%time:~3,2%-%time:~6,2%".csv echo %%G ) pause I am trying with this but that just create 2 .cvs. I have no idea from Batch and I think I am very far from my Target, could you help me please? Thank you very much in advance. Grüße Juan 回答1: There is

change file extension in batch

余生颓废 提交于 2019-12-11 13:06:57
问题 Simple question. IMDU command do imdu /b file.imd file.raw and convert the file.imd on file.raw I have a lot of .imd so i need a batch i have tried for %%x in (*.imd) do imdu /b %%x %%~nx.raw But doesn't work and create a file called %%.raw I need a batch wich remove extension imd and replace with raw How to do? 回答1: Open a command prompt window, run for /? and read the output help carefully and completely. There is explained %~xI – only file extension of %I – and %~nI – only file name of %I

Batch file rename - find and replace

自闭症网瘾萝莉.ら 提交于 2019-12-11 12:17:02
问题 I'm trying to write a Windows batch file to rename a set of files based on their original name. What I essentially want to do is find text within a file name and replace it with other text. For example, if the files had the naming structure "Family Christmas 001.jpg" I might want to change it to "Photos - Xmas 001.jpg". ie replace "Family Christmas" with "Photos - Xmas". This is just an example. I've found a piece of code from a user of this site, dbenham, that does almost exactly what I'm

How can we use the current directory path(%~dp0) with 'ren' command in a batch file?

末鹿安然 提交于 2019-12-11 11:45:58
问题 I want to rename a file which is present in the sub directory and the known part of the file name is ' .log '. When I try something like below ren subdirectory\*.log* file2.txt or ren .\subdirectory\*.log* file2.txt I get error : The syntax of the command is incorrect. I have two questions here: Do I always need to give full path in ren command for file1? If yes, then how can I we give the full path if I do not want to hard code it? I got to know that we can use ' %~dp0 ' to get the current

Removing text from the middle of a file name with batch renaming

萝らか妹 提交于 2019-12-11 06:27:50
问题 I'm trying to de-organize a series of video files named like this: Something or Other.s1e1.mp4 Another title.s1e2.mp4 ... Yet More Titles.s1e87.mp4 And so on. What I want to do is strip out the "s1eNUM" part of the filename and restore it back to normal, so I'd get "Something or Other.mp4" and "Yet More Titles.mp4" and such. Can this be done using Windows command line, with ren and batch files? Or do I need special software? Thanks!! 回答1: Use the for command. @echo off set YourFileName=title

Automatically batch renaming files according to a formula including parent folder name using Powershell

喜你入骨 提交于 2019-12-11 05:34:38
问题 How can I batch rename files in powershell using the following code: $nr=1;Get-ChildItem -Filter *.jpg | Rename-Item -Newname {"PPPPPPP_{0:d3}.jpg" -f $global:nr++} where PPPPPPP is the name of parent folder containing these files. Expected Output : PPPPPPP_001.jpg PPPPPPP_002.jpg PPPPPPP_003.jpg Files are located in C:\USER\MAIN\BLABLABLA\PPPPPPP folder. 回答1: Get the parent directory's name via $_.Directory.Name inside the script block. Cast the $nr variable to [ref] so that you can modify