Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
1answer
58 views

How to rename a file with different name?

I have a file named servername_test_LINUX_test_test_2019-04-19.xls I have to create multiple copies of this file, with the condition that server name should be changed in each file created e.g. ...
0
votes
1answer
43 views

Does changing Linux username give any problems?

I've installed Linux Mint on my old laptop. I created a username with the temporary use in mind so it is not that good name and I want to change it. I know how to change username and rename the ...
1
vote
2answers
53 views

Want to rename a files in folder with folder_1.txt folder_2.txt folder_n.txt name

I have 3 directories on my Ubuntu machine, named abc, xyz and pst. In each directory, I have approximately 7 files with different names. I want to rename each file like abc_1.txt, abc_2.txt, abc_3.txt,...
0
votes
1answer
20 views

Copy and rename files to a sequential numbering with subdirectories

I want to copy files of the given type with inside subdirectories. I think copy of the zzz.txt file works after copying the files in the abc_folder. How can i resolve this problem. AAA ---aaa.txt ...
0
votes
1answer
20 views

Copy only files with certain extension while renaming each file according to the parent folder

I have several directories: ├── folder1.x │   ├── dsferwe │   ├── ewrwr342 │   ├── analysis │   ├── fdsds │   ├── vcxvcxz │   ├── 324322 │   ├── export.asc │   ├── f_random_subfolder.xf │   │   ├── -....
0
votes
3answers
50 views

In a bash shell script, how to rename multiple files, keeping only the numbers and the extension of the original file names?

I have a directory with a bunch of files with names like this: generic name- dd -01 _.txt generic name- dd -02 _.txt generic name- dd -03 _.txt generic name- dd -04 _.txt And I want to rename all of ...
0
votes
1answer
39 views

Swap words and reformat date in a filename

I have several recordings with a file-name schema like this %year%month%day-%hour%minute%second__%phonenumber.amr e.g.: 20190212-112007__+313206601234.amr I want to swap words to obtain: %...
0
votes
1answer
29 views

batch rename files in Ubuntu: sequential numbering, based on order in directory. (Ubuntu 16.04)

I had to download videos from DVR in more trials. After that files were manually arranged by alphabetical order into few groups, in each group by numbers. It is necessary to have videos in former ...
10
votes
4answers
1k views

What's the difference between 'rename' and 'mv'?

It's not completely clear to me, but what is the difference between mv and rename (from util-linux-ng 2.17.2 as /usr/bin/rename)? Are there advantages of one over the other beyond rename accepting ...
-1
votes
0answers
30 views

Change names of Photo files based on date [duplicate]

I have thousands of photos with various names. I would like to sort them by changing the name to start with the image creation date, preferably from EXIF data.  prename works for my distro, being ...
1
vote
1answer
23 views

How to rename all md type files under subfolders recursive?

$ tree . . ├── tmp1 │   └── acsfd.md ├── tmp2 │   └── adb.md └── tmp3 └── aa23aa.md ... └── tmpn └── random.md Want to rename all md files to index.md, I tried: find . -name "*.md" -exec ...
0
votes
2answers
57 views

Bash: minus one to the sub string split by separator

I would like to batch rename filenames turning A-B-C#2-D.wav to A-B-C#1-D.wav. So for example: A-B-C#2-D.wav A-B-C#8-G.wav A-B-C6-E.wav becomes A-B-C#1-D.wav A-B-C#7-G.wav A-B-C5-E.wav So the ...
-1
votes
1answer
24 views

Rename a directory and subdirectory inside a directory having same name

I have a directory called Dual_Loop_PLL. Inside that I have 2 subdirectories: agent and test. Inside agent I have a directory called dl_pll_agent, and inside dl_pll_agent I have dl_pll_agent2. I want ...
-2
votes
1answer
22 views

Move files from one directory to another. But, rename files before the move if the destination directory already contains file of same name? [closed]

I need to move all the text files from /abc/d1 to /abc/d2, but files need to be renamed if /abc/d2 has files with the same name already. cd /abc/d1 mv *txt /abc/d2
-2
votes
2answers
31 views

how to remove all characters after and including “?” in filename?

I have a large amount of files that were downloaded and ended up having what looks like authentication parameters added to the filename which I would like to remove. Examples: file1.doc?...
0
votes
1answer
30 views

How to fix this command mass renaming files to match a text file [closed]

for file in *; do read line; mv -v "${file}" "${line}"; done < /var/www/html/uploads/songs.txt It works as in changing all 700 files. But it doesn't seem to do it in the correct order. I feel ...
1
vote
2answers
38 views

How do I mass remove certain characters from directory/file names

What's a command I could use to do this on fedora 29 I need to remove [,], and -. If possible just remove the characters. Otherwise I'm good with replacing them as '_' I have 2,400+ files and ...
0
votes
4answers
92 views

How to shuffle file names randomly in a directory

Say i have a directory of filenames: file_010.ext file_011.ext ... file_99.ext What's the simplest way to take each file and randomly rename it to any other name in the directory, without there ...
-1
votes
2answers
50 views

How to batch rename files in folder [closed]

I have a zip file where each file is named the following original.jpg.1.png original.jpg.2.png The files are actually jpegs How do I go about renaming them to the following? original1.jpg original2....
1
vote
2answers
106 views

How to mass rename files with regular expressions [closed]

I have a bunch of folders in a directory with files in them. Most of the filenames have region codes (retropie), and the scrubber will not match roms with single letter region codes (u,j,e,etc.). I ...
0
votes
2answers
38 views

Rename files with zero padded numbers while keeping extension using “rename” command

I want to rename files with zero padded numbers while keeping extension. Example a.abc b.cde c.xyz to be renamed as 001.abc 002.cde 003.xyz :~/x$ rename -n -v 's/.+/our $i; sprintf("%03d.jpg", ...
0
votes
3answers
44 views

Move or rename subfolders

I have a folder structure like this: /ms/files/a/ /fb/files/a/ /db/files/a/ It should be like this: /ms/files/b/ /fb/files/b/ /db/files/b/ I can find the folders I need to move or rename using ...
1
vote
2answers
52 views

Finding a rogue script changing filenames?

I've got a server that is used as an SFTP endpoint and a script living somewhere else that periodically uploads to the server. At a particular time every day all the files in the upload folder get ...
0
votes
2answers
98 views

Use FIND with MV to rename files. Delete the found string then prepending it to the filename?

find . -type f -name '*authors-name-string*' -exec bash -c 'mv "$0" "${0/authors-name-string/}"' {} \; I am trying to rename files nested in several layers of directories that contain an author's ...
1
vote
1answer
113 views

Batch to rename episodes

im trying to create a bash to automate rename files from, if for an anime: Example: [TAG] One Piece - 01 [Quality].mkv to: [TAG] One Piece - S01E01 [Quality].mkv But this isnt always because i ...
1
vote
1answer
55 views

Terminal: rename multiple JPG files to HEIC format giving a condition

I have a folder where there are many pictures taken with my iPhone. Turns out that half of them are JPGs and half of them were supposed to be HEIC format. For some reason, all pictures in this folder ...
1
vote
1answer
75 views

How to rename files with sequential names to an another sequence using Terminal?

I have a directory that has files in it that are named 'o1.ray' to 'o293.ray'. I want to move them to an another directory while renaming them 'o132.ray' to 'o424.ray'. How can I do this in the ...
1
vote
4answers
185 views

Script to rename a large number of files using the text in each file to rename

I am trying to devise a solution to rename a large collection of files so that the text in line 3 of each file is the new filename. These files all have the same structure. These are HTML files and ...
0
votes
2answers
44 views

Batch rename a lot of file using a number find in filename

I have hundred of file name with a number tag in filename like this: AAAA #12 SSSS.TXT BBB #231 CDF.TXT CDFSDAAAA #1 AAAASS.TXT and i want to rename so: #012 - AAAA #12 SSSS.TXT #231 - BBB #231 CDF....
1
vote
2answers
147 views

Rename files with consecutive numbers [duplicate]

I have about a thousand files that all look something like this: 20091208170014.nc 20091211150704.nc 20091214131328.nc 20091217111953.nc 20091220092643.nc 20091223073308.nc ...
0
votes
2answers
72 views

Bash-Script: rename files in folder order by file-date

I want to rename files in order of file-date; from example: file_1.pdf file_2.pdf to: file_1_ONE.pdf file_2._TWO.pdf The script must rename the first file to "ONE" ordered by file-date.
2
votes
5answers
621 views

I want to rename all files in a directory from *.ts to *.mkv [duplicate]

Rename all the files in .ts files in a directory My echo command works but not if I try to make it a new variable. #!/bin/sh for file in "${1}"/*.ts; do echo ${file} | sed -e 's|.ts|.mkv|' ...
0
votes
0answers
18 views

How to rename ISPConfig directories set by chattr command

I would to import a restore of a web directories to /var/www/clients/client4/web18/web managed by ISPConfig. I read ISPConfig put an attributes on this kind of directories. /var/www/clients/...
0
votes
2answers
62 views

Remove part of name after regex

I have a number of video files using a naming scheme like some-words-SxxExx.extension which is my preference. Unfortunately I have a lot of files in this format some-words-SxxExx-words-I-want-to-...
0
votes
1answer
34 views

Change file name while copying based on source path

I have a large number of files in directories of the format */*/*/*/*.txt and I would like to copy them into a different place while replacing the forward-slashes in the path with underscores. For ...
1
vote
2answers
100 views

Remove file-name extension, if it exists

Very new to scripting. I have a directory containing some text files and some with text files that also contain an additional extension (.xfr) e.g. file1.txt, file2.txt.xfr, file3.txt, file4.txt.xfr. ...
0
votes
1answer
60 views

How to use a Bash Script to move and rename files with grep

Hi I an FTP folder called Input where I get sent files which look something like this: "Guide to Iceland _ Chen-ping Wang itinerary T-987654987.pdf" "Guide to Iceland _ T-123654875 Chen-ping Wang ...
0
votes
2answers
32 views

Renaming part of name of all files in a directory tree if match

I have a directory tree like this . |-- players | |-- red_alice.plr | |-- red_bob.plr |-- resources | |-- red_cash.rsc | |-- red_food.rsc I want to go through all directories and rename any ...
8
votes
3answers
654 views

Flattening directory hierarchy preserving directory names in new directory name

I basically want to go from this: . ├── Alan Walker │   ├── Different World │   │ ├── 01 Intro.mp3 │   │ ├── 02 Lost Control.mp3 │   │ └── cover.jpg │   └── Same World │   ├── 01 Intro.mp3 │...
0
votes
2answers
73 views

want to Rename Images In Bulk in Linux

I have more than 1 million images with name of love-images-250x120.jpg 7788855441122-love-images-250x120.jpg us-wallpapers33344.jpg 77441144desktop-wallpapers.jpg desktop-wallpapers1144141411.jpg I ...
0
votes
5answers
98 views

Renaming files by extracting parts of filenames that match with a pattern

I want to know which command I can use to rename files like this. Let's say, for instance, the old filenames are: 0_predict-1-500.png 0_predict-2-500.png 0_predict-3-500.png 1_predict-1-500.png ...
3
votes
2answers
153 views

Bash - replace spaces with underscore but replace multiple spaces with one

I use rename to underscore spaces in filenames, simply with: rename "s/ /_/g" * but I encounter the problem that files downloaded from the internet often have multiple spaces. A nasty workaround I ...
1
vote
0answers
21 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
42 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
38 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
61 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
vote
2answers
51 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
70 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
40 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
191 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: ...