file-rename

Script to rename files

巧了我就是萌 提交于 2019-12-04 11:30:13
I have about 2200 different files in a few different folders, and I need to rename about about 1/3 of them which are in their own subfolder. Those 700 are also in various folders as well. For example, there might be The top-most folder is Employees, which has a few files in it, then the folder 2002 has a few, 2003 has more files, 2004 etc. I just need to attach the word "Agreement" before the existing name of each file. So instead of it just being "Joe Schmoe.doc" It would be "Agreement Joe Schmoe.doc" instead. I've tried googling such scripts, and I can find stuff similar to what I want but

How to rename files using os.walk()?

一笑奈何 提交于 2019-12-04 06:24:11
问题 I'm trying to rename a number of files stored within subdirectories by removing the last four characters in their basename. I normally use glob.glob() to locate and rename files in one directory using: import glob, os for file in glob.glob("C:/Users/username/Desktop/Original data/" + "*.*"): pieces = list(os.path.splitext(file)) pieces[0] = pieces[0][:-4] newFile = "".join(pieces) os.rename(file,newFile) But now I want to repeat the above in all subdirectories. I tried using os.walk(): import

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

吃可爱长大的小学妹 提交于 2019-12-04 00:29:34
问题 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

Rename file in DocumentDirectory

六眼飞鱼酱① 提交于 2019-12-03 09:41:54
I have a PDF file in my DocumentDirectory . I want the user to be able to rename this PDF file to something else if they choose to. I will have a UIButton to start this process. The new name will come from a UITextField . How do I do this? I'm new to Swift and have only found Objective-C info on this and am having a hard time converting it. An example of the file location is: /var/mobile/Containers/Data/Application/39E030E3-6DA1-45FF-BF93-6068B3BDCE89/Documents/Restaurant.pdf I have this code to see check if the file exists or not: var name = selectedItem.adjustedName // Search path for file

How to rename the downloaded file with wget?

北慕城南 提交于 2019-12-03 03:27:47
问题 To download the SOFA Statistics from the server I use the wget command: wget -c http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp The filename of downloaded file in this case is download?source=files . If I add the --output-document option to the command, to rename the output file to sofastatistics-latest.deb , the format of downloaded file is not recognized by dpkg package. dpkg-deb: error: `sofastatistics-latest.deb' is not a debian format archive How to rename

generate random string in php for file name [duplicate]

馋奶兔 提交于 2019-12-03 00:28:23
This question already has an answer here: PHP: How to generate a random, unique, alphanumeric string? 27 answers How would I go about creating a random string of text for use with file names? I am uploading photos and renaming them upon completion. All photos are going to be stored in one directory so their filenames need to be unique. Is there a standard way of doing this? Is there a way to check if the filename already exists before trying to overwrite? This is for a single user environment (myself) to show my personal photos on my website however I would like to automate it a little. I don

Rename part of file name based on exact match in contents of another file

删除回忆录丶 提交于 2019-12-02 20:16:25
问题 I would like to rename a bunch of files by changing only one part of the file name and doing that based on an exact match in a list in another file. For example, if I have these file names: sample_ACGTA.txt sample_ACGTA.fq.abc sample_ACGT.txt sample_TTTTTC.tsv sample_ACCCGGG.fq sample_ACCCGGG.txt otherfile.txt and I want to find and replace based on these exact matches, which are found in another file called replacements.txt: ACGT name1 TTTTTC longername12 ACCCGGG nam7 ACGTA another4 So that

How to rename the downloaded file with wget?

冷暖自知 提交于 2019-12-02 17:13:53
To download the SOFA Statistics from the server I use the wget command: wget -c http://sourceforge.net/projects/sofastatistics/files/latest/download?source=dlp The filename of downloaded file in this case is download?source=files . If I add the --output-document option to the command, to rename the output file to sofastatistics-latest.deb , the format of downloaded file is not recognized by dpkg package. dpkg-deb: error: `sofastatistics-latest.deb' is not a debian format archive How to rename correctly the downloaded file with wget? UPDATE - Jan 08 '15 With the provided link the downloaded

How to rename files using os.walk()?

*爱你&永不变心* 提交于 2019-12-02 07:57:50
I'm trying to rename a number of files stored within subdirectories by removing the last four characters in their basename. I normally use glob.glob() to locate and rename files in one directory using: import glob, os for file in glob.glob("C:/Users/username/Desktop/Original data/" + "*.*"): pieces = list(os.path.splitext(file)) pieces[0] = pieces[0][:-4] newFile = "".join(pieces) os.rename(file,newFile) But now I want to repeat the above in all subdirectories. I tried using os.walk() : import os for subdir, dirs, files in os.walk("C:/Users/username/Desktop/Original data/"): for file in files:

Batch File to replace underscores with spaces in a filename

隐身守侯 提交于 2019-12-02 05:46:59
问题 I am trying to replace underscores in some file names with spaces, for example: this_is_a_file.pdf becomes: this is a file.pdf In Windows using a batch file. I have found a similar question, but it replaces spaces with nothing: How to remove spaces from file names (in bulk) Can it be easily translated to do what I want? 回答1: Use %file:_= % to represent %file% with underscores replaced with spaces. Unfortunately this won't work on a for variable so if you're looping over files you have to use