Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rename]

The rename tag refers to the action of giving a different name to either an existing file or to a copy of a file as part of some other operations (.e.g. remote copy, backup). Use this tag as well for questions related to the (perl) rename command.

1
vote
0answers
15 views

Renaming many files to their parent directory name [duplicate]

I want to recursively change many files named raw.tex to parent-directory-hw.tex. Is there a simple scripting solution to this problem? For example, running the script on . `-- root |-- baz |...
0
votes
1answer
39 views

Unix - replace filenames with unique prefixes in a directory with specific unique prefixes from a file in the same directory

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this: ABC01234.sorted_dup.bam ABC04271.sorted_dup.bam ABC09287.sorted_dup.bam I have a file with ...
2
votes
2answers
34 views

Rename a specific part of a lot of files [duplicate]

I have a bunch of files named: Brooklyn Nine-Nine S01 E01 [H264].mkv Brooklyn Nine-Nine S01 E02 [H264].mkv Brooklyn Nine-Nine S01 E03 [H264].mkv Brooklyn Nine-Nine S01 E04 [H264].mkv Brooklyn Nine-...
0
votes
1answer
34 views

Rename multiple files using sed command after removing the string after the last underscore [closed]

I have a set of files in a directory as shown below and I want to remove the string after the occurrence of the last underscore from it. The string may be different each time. It will be good if it ...
-1
votes
0answers
16 views

How to rename a file named '-I'? [duplicate]

So I used the curl command curl -o -I and now I have a file named -I in my current directory. I'd like to rename it to curl.out Neither mv -I curl.out nor mv "-I" curl.out nor mv \-I curl.out work....
1
vote
2answers
38 views

Make script to create subdirectories based on file name and move matching files into it [duplicate]

A folder has a huge number of files; each pair of files has the same name but different extensions (.obj and .mtl). I want to make a folder for each pair of files with the same name, then move each ...
0
votes
2answers
45 views

Batch rename media files

I have an Enigma2 FreeSat recorder that I've now hooked up to my Plex Media Server. Plex can see and play the files from the Enigma2 just fine, but the file naming makes this unattractive. How can I ...
0
votes
3answers
38 views

move a list of files to a list of locations

I'd like to move multiple files at the same time to specific new locations. Say I have the following wrong name | c.txt | a.txt | b.txt | Correct name| a.txt | b.txt | c.txt | I'd then like to ...
2
votes
3answers
149 views

'rename' with expression|replacement with a leading '-' (hyphen|minus)

I have many files like xyz_123_foo.ext for which I would like to add -bar to the filenames at the end to result in xyz_123_foo-bar.ext. I tried: rename . -bar. xyz_* which resulted in: rename: ...
0
votes
2answers
56 views

How can I change lower to upper using (three) parameters in bash? [closed]

I have to make a bash script that will be changing files' names from lower to upper OR from upper to lower via parameters in command line. So when I put in command line: ./bashScript lower upper ...
1
vote
4answers
57 views

How to rename files pulled from a list of files using a single command or line

I have a project named my-project with the following file tree. my-project/ (before) . ├── src │ ├── index.html │ ├── main.js │ ├── normalize.js │ ├── routes │ │ ├── index.js │ │ └── ...
0
votes
2answers
33 views

delete then rename: same filenames different extensions

I have a directory containing thousands of files, each file has a duplicate. An example: file1.txt file1.jpg.txt file2.txt file2.jpg.txt I want to delete all *.txt files, and leave the *.jpg.txt ...
-1
votes
1answer
23 views

Rename files on QNAP linux (batch)

I have a folder with at least 30 files. The names are: 123456_12_12_AB12_NAME.mp4?BWSQv6seywG5ND2Myt7YM3JHPmaaNmtBRI0PcXbYpqoS01ivTvL0HCHvjfjFtOM9AMq7-kpHUZ0W_m8njEjqBkM9uyngsnKANw How can I get ...
1
vote
2answers
28 views

Batch rename files to move sequence from end to beginning

I have a bunch of files that are from using IM's convert from a PDF to many image thumbnails. On that conversion, I have files named something-0.jpg. So, say a PDF has 45 pages, each page is: ...
0
votes
3answers
46 views

Remane filename by switching what is before and after an underscore

I would like to rename a number of files that have the following formatting: ABCD_20181102.jpg DEDE_2_20181030.jpg i.e usually 4 random letters, followed by an underscore and a date (year, month, ...
3
votes
1answer
56 views

Atomically write a file without changing inodes (preserve hard link)

The normal way to safely, atomically write a file X on Unix is: Write the new file contents to a temporary file Y. rename(2) Y to X In two steps it appears that we have done nothing but change X "...
1
vote
2answers
64 views

Removing digits from beginning of filename [duplicate]

I was hoping this would work: $ find . -type f -exec basename {} \; | while EFS= read -r f; do echo "${f##[0-9]}"; done But, for example, for files named as: 1foo 11bar it returns: foo ...
0
votes
4answers
82 views

Recursively rename all the files without changing their extensions?

How to recursively rename all the files in several layers of subdirectories without changing their extensions? Below's a toned down version (to save room) of what I've got. For argument's sake, I ...
2
votes
2answers
82 views

trying to Rename multiple file names within all directories of a project

ive recently been trying to change the names around in my project and have been having some trouble getting the task done properly. my problem is when I try to use find . -type f -print0 | xargs -0 ...
-1
votes
3answers
41 views

Renaming files by the day they created

I have files I would like to rename it using the date they created. How can I do this automatically? Looking at the properties for every file then renaming it is a real pain. For example In a folder ...
2
votes
2answers
101 views

how to increase the file extension numerically by one

under the following current folder, we have the example of files lok.log.1 df.log.6 weq.log.90 vr.log.11 vs.aw.frsd.log.3 we want to increase the files extension by 1 so the expected output will be ...
0
votes
2answers
80 views

Rename files based on list

I have these video files; Fringe.S03E01.mkv Fringe.S03E02.mkv Fringe.S03E03.mkv etc... I also have a .csv text file of the episode's titles; 01,Olivia 02,The Box 03,The Plateau etc... what I am ...
0
votes
2answers
63 views

How to rename multiple files into one name [duplicate]

I would like to rename these files; 2000.jpg B001.jpg 9002.jpg D006.jpg to these names below ICON000.jpg ICON001.jpg ICON002.jpg ICON006.jpg respectively.
-1
votes
1answer
20 views

how to rename a remote repo name so that it makes sense to you while git cloning [duplicate]

Usually the way I do renames to make sense for myself is - $ git clone <remote URL.git> $ mv remotedir nameIwant I was wondering if there is a better way to do it. The reason is sometimes ...
0
votes
1answer
159 views

Renaming a file on FTP server with a timestamp variable

From my linux machine, I connect remotely to an FTP server using the following command: ftp ftp://USERNAME:PASSWORD@FTPSERVER/array1/DIR1/DIR2/ In this DIR2 there is a file called running_config ...
2
votes
2answers
40 views

How to rename multiple files containing _ and .?

In linux bash shell, I have multiple tif files (around 1000) as follows: Sep04_17.00.37.tif Sep04_17.05.54.tif Sep04_17.08.41.tif Sep04_17.02.02.tif Sep04_17.07.17.tif How Can I remove the _ and ....
3
votes
2answers
205 views

Renaming files to remove parenthesized strings

I have a collection of files with names like these: Ace of Aces (Europe).mp4 Action Fighter (USA, Europe) (v1.2).mp4 Addams Family, The (Europe).mp4 Aerial Assault (USA).mp4 After Burner (World).mp4 ...
0
votes
3answers
112 views

How to rename multiple directories?

Here are my directories: P [001] P [002] P [003] I want to rename to: P001 P002 P003 I used the code: for P in *\ *; do mv '$P' '${P// /_}'; done but I am missing something.
1
vote
1answer
31 views

batch rename folders with value from json value in package.json

This is a bit of a crazy one, but I am wondering if it is even possible. I have maybe 300 folders in my /var/www folder that were all renamed to the same name [Name](Num) so kindred (19) for example. ...
0
votes
1answer
33 views

Rename Files to Consecutive Integers [duplicate]

I have bunch of files in one directory, like these: 0002.b3120c4bcbf3101e661161ee7efcb8bf 0003.acfc5ad94bbd27118a0d8685d18c89dd 0004.e8d5727378ddde5c3be181df593f1712 0005....
0
votes
3answers
75 views

Unix command to remove space from a file name

I have a file whose file name has a space like First Name_20180810.csv. The date (20180810 in the above example) changes daily in the filename. How can I rename First Name_*.csv to be FirstName_*.csv?...
1
vote
3answers
109 views

Trying to change multiple files' extensions

Using the command line (in Fedora) I'd like to rename all the files in the current directory, that have "foo" for the extension, to the same name but with foo1 for the extension. I've tried several ...
0
votes
1answer
39 views

Rename files in bash scripted based on file modified date

It has been awhile since I have had to drive into shell scripting. However, I have a shell script where I'm renaming files based on the file extension from a ftp upload. Currently, the files are ...
6
votes
4answers
527 views

Change some file names (prefix to postfix)

I have a directory containing thousands of files with names t_00xx_000xxx.png and 00xx_000xxx.png. I want to change the names of the files which starts with t_, like t_00xx_000xxx.png to 00xx_000xxx_t....
8
votes
4answers
312 views

Rename multiple files with 2 conditions/replacements in one line?

I'm trying to rename a few images: IMG_1.JPG IMG_2.JPG IMG_3.JPG I want to replace IMG with img and .JPG with .jpg - I know how to do the second part: $ rename 's/\.JPG$/\.jpg/' *.JPG My problem ...
0
votes
2answers
41 views

Reverse-exchange file names of files in a folder from bottom up

I have a some jpg files in a certain folder: hg_test_spr.jpg hg_test00001.jpg hg_test00002.jpg hg_test00003.jpg hg_test00004.jpg hg_test00005.jpg hg_test00006.jpg . . . hg_test01200.jpg I want to ...
2
votes
3answers
138 views

Batch rename file by substring the filename

I have files .. 00016_0912RP10R6_RampMotorway9_0912RP10R6_13.646852_100.687103.jpg 00017_0912RP10R6_RampMotorway9_0912RP10R6_13.646956_100.686897.jpg 00018_0912RP10R6_RampMotorway9_0912RP10R6_13....
0
votes
1answer
90 views

using Find -exec to rename a file with the grepped contents of the file

I'm attempting to get a list of files with find and then use pdfgrep to get a string from the file, then rename the file with that string. The commands broken down are: find . -name "*...
0
votes
0answers
26 views

How to swap order of extensions of matching files? [duplicate]

I am merging two folders with the following command: rsync -a --checksum --backup --suffix=.merge-bkup src/ dst/ The idea is that if a file exists in both folders, both versions are preserved. ...
1
vote
1answer
244 views

Bash - Recursive directory/file rename

I have the following script, that will replace all spaces in files and directories recursively: ################### SETUP VARIABLES ####################### number=0 # Number of ...
0
votes
1answer
45 views

How to trim the tail number of the file via shell script?

I have the files as below. There are four files in total: cert1.pem chain1.pem fullchain1.pem privkey1.pem I want to trim the tail number of each file (1 here). How do I use a shell script to ...
0
votes
2answers
99 views

How to find/replace characters in a folder name?

I want to perform the following operations: Find/replace (using regexp) all occurrences of <>:"\|? and replace it with an empty string Find/replace (using regexp) all occurrences of ^\.+|\.+$ ...
0
votes
2answers
28 views

Renaming directories with specific extensions

An extension to the previous question that I asked: Rename an alphanumeric file I have a directory that has subdirectories with an extension of *_upstream: DHX30_vs_Control18....
3
votes
2answers
380 views

Is mv atomic operation between two file systems?

Is moving a file via the mv command between two filesystems an atomic operation?
0
votes
0answers
23 views

Linux Mint to Windows Server via SMB: find, copy rename with pwd - save to netwok location

I am trying to find file of various types (*.pst), append their directory location to the current file name and copy them from a local hard drive to a network location. find . -name '*.pdf' | cpio -...
2
votes
1answer
186 views

is there a way to atomically move file and directory from tempfs to ext4 partition on eMMC

We have beaglebone black based custom board with 256MB RAM and 4GB eMMC. Board runs Linux kernel 4.9 we are running into a situation where we create a file in tempfs and then after validation, we ...
1
vote
1answer
32 views

Inline replace comments in files recursively

I have tried using the cloc tool with the --strip-comments parameter, which is correctly stripping the comments from all files recursively, with 2 issues: it cannot do it "in-place" the resulting ...
3
votes
3answers
199 views

Rename an alphanumeric file

I have following files in a directory: GE.AARS_vs_Control16.txt GE.DHX30_vs_Control18.txt GE.DNAJC2_vs_Control18.txt I would like to remove the *_Control<numeric> and replace it with *...
1
vote
2answers
47 views

How can I copy a file and paste it as a different name?

I have a file test.txt in directory A/B. I want to copy test.txt to A/C and rename it newtest.txt. I know I can use the cp and mv commands to do this, but the issue is that there already is a test....
0
votes
3answers
35 views

Rename multiple directories using rename command, name involves parenthresis

I've got a list of directories marked with "(Done)" at the end of the label. For example: "Folder 1 (Done)" I'm looking to remove "(Done)" from each directory using the rename command. Because it's ...