Questions tagged [file-rename]

rename-file means changing name of a file

renaming a file means changing name of a file. Almost all operating systems allow to change the name of a file after it has been created with some other name. Usually a platform provides a GUI and a CLI interface to allow users to rename a file, as well as API interfaces to rename a file programmatically.

1299 questions
542
votes
10 answers

Changing capitalization of filenames in Git

I am trying to rename a file to have different capitalization from what it had before: git mv src/collision/b2AABB.js src/collision/B2AABB.js fatal: destination exists, source=src/collision/b2AABB.js, destination=src/collision/B2AABB.js As you can…
knpwrs
  • 13,484
  • 10
  • 56
  • 98
518
votes
26 answers

How do I rename the extension for a bunch of files?

In a directory, I have a bunch of *.html files. I'd like to rename them all to *.txt How can I do that? I use the bash shell.
bmw0128
  • 12,710
  • 22
  • 65
  • 110
452
votes
14 answers

How to rename a file using Python

I want to change a.txt to b.kml.
zjm1126
  • 52,371
  • 71
  • 163
  • 213
408
votes
15 answers

Rename multiple files in a directory in Python

I'm trying to rename some files in a directory using Python. Say I have a file called CHEESE_CHEESE_TYPE.*** and want to remove CHEESE_ so my resulting filename would be CHEESE_TYPE I'm trying to use the os.path.split but it's not working properly.…
Jeff
  • 4,091
  • 3
  • 14
  • 4
185
votes
14 answers

Rename a file using Java

Can we rename a file say test.txt to test1.txt ? If test1.txt exists will it rename ? How do I rename it to the already existing test1.txt file so the new contents of test.txt are added to it for later use?
Shekhar
132
votes
6 answers

How to do a git diff on moved/renamed file?

I moved a file using git mv. Now I would like to do a diff on the new file to compare it with the old file (with the old, now non-existent name). How do I do this?
dr jerry
  • 8,982
  • 21
  • 70
  • 112
132
votes
8 answers

How to Batch Rename Files in a macOS Terminal?

I have a folder with a series of files named: prefix_1234_567.png prefix_abcd_efg.png I'd like to batch remove one underscore and the middle content so the output would be: prefix_567.png prefix_efg.png Relevant but not completely…
kidnim
  • 1,317
  • 2
  • 9
  • 13
111
votes
10 answers

Batch renaming files with Bash

How can Bash rename a series of packages to remove their version numbers? I've been toying around with both expr and %%, to no avail. Examples: Xft2-2.1.13.pkg becomes Xft2.pkg jasper-1.900.1.pkg becomes jasper.pkg xorg-libXrandr-1.2.3.pkg becomes…
Jeremy L
  • 7,138
  • 4
  • 27
  • 36
94
votes
13 answers

Using sed to mass rename files

Objective Change these filenames: F00001-0708-RG-biasliuyda F00001-0708-CS-akgdlaul F00001-0708-VF-hioulgigl to these filenames: F0001-0708-RG-biasliuyda F0001-0708-CS-akgdlaul F0001-0708-VF-hioulgigl Shell Code To test: ls F00001-0708-*|sed…
Daniel Underwood
  • 943
  • 1
  • 7
  • 5
83
votes
3 answers

How to rename the downloaded file with wget?

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…
Iurie Malai
  • 1,702
  • 2
  • 16
  • 31
76
votes
5 answers

How to rename uploaded file before saving it into a directory?

Below is the code I used in order to upload files into a directory. It works fine. My main question is: move_uploaded_file() is the one that saves the uploaded file into the directory, and it is also my guess that move_uploaded_file() is the one…
70
votes
3 answers

Rename multiple files, but only rename part of the filename in Bash

I know how I can rename files and such, but I'm having trouble with this. I only need to rename test-this in a for loop. test-this.ext test-this.volume001+02.ext test-this.volume002+04.ext test-this.volume003+08.ext test-this.volume004+16.ext…
user3115029
  • 709
  • 1
  • 5
  • 3
65
votes
10 answers

How can I batch rename files using the Terminal?

I have a set of files, all of them nnn.MP4.mov. How could I rename them so that it is just nnn.mov?
Jake Wilde
  • 653
  • 1
  • 5
  • 4
64
votes
2 answers

How do I rename files using R?

I have over 700 files in one folder named as: files from number 1 to number9 are named for the first month: water_200101_01.img water_200101_09.img files from number 10 to number30 are named: water_200101_10.img water_200101_30.img And so on…
sacvf
  • 2,213
  • 5
  • 29
  • 51
62
votes
7 answers

Enforce unique upload file names using django?

What's the best way to rename photos with a unique filename on the server as they are uploaded, using django? I want to make sure each name is used only once. Are there any pinax apps that can do this, perhaps with GUID?
zjm1126
  • 52,371
  • 71
  • 163
  • 213
1
2 3
86 87