file-rename

Pad numerical values in filename with three digit value using sed

北战南征 提交于 2019-12-02 04:10:50
问题 I am passing a filename into my bash script and cleaning the name using sed. A few sample files would be: Test 01.txt Test v2 01.txt I would like to get back: Test 001.txt Test v002 001.txt Here is my script #!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") for f in $@ do j=`basename "$f" ".???"` BASENAME=`basename "$f" ".???"` DIRNAME=`dirname "$f"` j=`echo $j |sed -e 's/\///g'` j=`echo $j |sed -e 's/_/ /g'` j=`echo $j |sed -e 's/^\.//'` j=`echo $j |sed -e 's/\[[^()]*\]//g'` j=`echo $j |sed -e

Windows REN command with wildcards doesn't work

删除回忆录丶 提交于 2019-12-02 01:34:27
Ok, I know the typical format for the REN command REN source dest and there are several examples to rename using wildcards. Example: REN *.txt *.doc This will rename all your .txt files to .doc. Well, this is all fine and dandy, but I have a bunch of files with extensions .aaaa.bbbb and when I use the command: REN *.aaaa.bbbb *.aaaa I get all of my files with the extenstion .aaaa.aaaa. Now I cannot come up with a REN command to just get .aaaa extension. dbenham ren *.aaaa.bbbb *. For an explanation as to why this works, see How does the Windows RENAME command interpret wildcards? interesting

Pad numerical values in filename with three digit value using sed

允我心安 提交于 2019-12-01 23:24:59
I am passing a filename into my bash script and cleaning the name using sed. A few sample files would be: Test 01.txt Test v2 01.txt I would like to get back: Test 001.txt Test v002 001.txt Here is my script #!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") for f in $@ do j=`basename "$f" ".???"` BASENAME=`basename "$f" ".???"` DIRNAME=`dirname "$f"` j=`echo $j |sed -e 's/\///g'` j=`echo $j |sed -e 's/_/ /g'` j=`echo $j |sed -e 's/^\.//'` j=`echo $j |sed -e 's/\[[^()]*\]//g'` j=`echo $j |sed -e 's/([^()]*)//g'` j=`echo $j |sed -e 's/#//g'` j=`echo $j |sed -e 's/+/\ /g'` j=`echo $j |sed -e 's/\.\

How do I rename a file in JGit

大憨熊 提交于 2019-12-01 21:33:48
How do I rename a file in JGit. That is, given a working file named file1. The command line would be: git mv file1 file2 There is no direct equivalent to git mv in Git. git mv is just a short hand for mv oldname newname git add newname git rm oldname (see here) Respectively, use File.renameTo() or, since Java 7, Files.move() to move the file and then git.add().addFilepattern( "newname" ).call(); git.rm().addFilepattern( "oldname" ).call(); to update the Git index. The paths given to addFilePattern() must be relative to the work directory and path segments must always be separated by slashes (

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

Renaming all files in a folder

牧云@^-^@ 提交于 2019-12-01 13:23:18
问题 I'm wondering if it's possible to rename all the files in a folder with a simple program, using vb.NET I'm quite green and not sure if this is even possible. Lets say there is a folder containing the files: Text_Space_aliens.txt, fishing_and_hunting_racoons.txt and mapple.txt. Using a few credentials: Dim outPut as String = "TextFile_" Dim fileType as String = ".txt" Dim numberOfFiles = My.Computer.FileSystem.GetFiles(LocationFolder.Text) Dim filesTotal As Integer = CStr(numberOfFiles.Count)

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

Python rename files reading names from csv file

耗尽温柔 提交于 2019-12-01 11:48:49
Hi there i've been trying to adapt this to my needs but I'm just a newbe in python, I have a csv file with multiple columns and rows, important columns are 1 = old name of file, and 2 = new name of file, so I need to go the directory where the files listed in csv file are and rename them to the new name of column 2, as I say I've tried many things without success, I paste the last code I've made so you have an idea: import os, unicodecsv as csv, sys IDs = {} #open and store the csv file with open('documentos_corpus_ladino.csv','rb') as csvfile: timeReader = csv.reader(csvfile, delimiter = ',')

Python rename files reading names from csv file

纵饮孤独 提交于 2019-12-01 11:47:29
问题 Hi there i've been trying to adapt this to my needs but I'm just a newbe in python, I have a csv file with multiple columns and rows, important columns are 1 = old name of file, and 2 = new name of file, so I need to go the directory where the files listed in csv file are and rename them to the new name of column 2, as I say I've tried many things without success, I paste the last code I've made so you have an idea: import os, unicodecsv as csv, sys IDs = {} #open and store the csv file with

Git on windows: Can't switch branch after renaming a file (only changed case)

假如想象 提交于 2019-12-01 03:19:51
I'm working with git on windows, and I have a file in my repo, lets say "foo.txt". Today I wanted to rename this file to "Foo.txt" (uppercase). As suggested in this SO question , I used git mv -f foo.txt Foo.txt , which produced the desired result. I proceeded to commit the change to my repo. EDIT: I would like this to be a permanent change, and still be able to checkout commit that predate this change. However, after that I encountered an error upon trying to switch branch: # I'm on branch1 git checkout branch2 Aborting error: The following untracked working tree files would be overwritten by