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
26 views

Rename non alphabetical & numeric characters in files with nothing

I have a load of .jpg files in a folder that have non alphabetical characters like ! , ( ) ^ & . and more. I need to rename the files so that anything that is not A-Z a-z 0-9 is replaced with ...
0
votes
2answers
49 views

Sort and mv files based on filename (with spaces), recursively

I have made a mistake and dumped files together into the same directory. Luckily I can sort them based on the filename: ''' 2019-02-19 20.18.58.ndpi_2_2688_2240.jpg ''' Where the # bit or 2 in this ...
1
vote
3answers
44 views

Remove character pattern at beginning and end of filenames

I have a bunch of files that I'd like to rename. Their filenames are in a certain format: p1.uniquenameA#blah_a p2.uniquenameB#blah_b p3.uniquenameC#blah_c p4.uniquenameD#blah_d p5.uniquenameE#blah_e ...
0
votes
1answer
36 views

How to rename a bulk of files and remove extension

I am need to rename the below files. I only want to remove .job-209675 from the filenames that begin with SOA but keeping the original filenames intact as there are other files in this directory for ...
0
votes
2answers
46 views

how to detect files rename, without snapshot

I am currently monitoring directories with subdirectories, and I need to detect file rename. what I do is making a md5sum of all files and a keep a file list on another place, and from time to time ...
3
votes
2answers
105 views

Rename photos to match video titles

I have a mostly automated media server and currently have everything going into one folder and being sorted out by file extension into the correct locations. At the moment the photos are coming in ...
0
votes
5answers
83 views

Special “copy and rename” case

I have a deeply nested folder structure in which there are hundreds of files called data.log. I need a script to rename each of these data.log files according to the name of the parent folder they are ...
0
votes
2answers
49 views

Get filenames and write them on place of previous namespace

I have hundreds of sources codes files. I want to rename namespace according to the filenames path. Of course slashes must be replace by dots. I have tried with find -exec but I failed to get the ...
2
votes
1answer
229 views

How to modify this `while read; mv printf` code to rename only files of certain filetype?

Code in question: ls | cat -n | while read n f; do mv "$f" `printf "video_%03d.mp4" $n`; done The above code will rename all files/folders within the directory executed to: video_001.mp4 video_002....
12
votes
4answers
1k views

How to rename multiple files in a directory at the same time

I have directory say /var/tmp/abc which has 4 files: 12345-ram-3e3r5-io9490-89adu9.csv 45434-dam-qwe35-to9490-43adu9.csv 11234-cam-yy3r5-ro9490-85adu9.csv 14423-sam-hh3r5-uo9490-869du9.csv I want to ...
0
votes
0answers
24 views

Renaming multiple files in specific order

I am looking to rename the 137 .jpg files from a directory with numbers from 1 to 137 keep the same order. The files look like this: IMG_20190512_164221.jpg IMG_20190512_171322.jpg ...
1
vote
2answers
169 views

wget download files from a file list, how to specify names for each of the downloaded file?

When downloading a single file, we can use wget's -O option to specify the file name. When I'm downloading Urls in a file using wget -i filelist.txt (filelist.txt contains list Of Urls I want to ...
3
votes
1answer
54 views

Find files then move them and rename them at the same time?

Currently I use three steps to gzip some static assets and then use s3cmd to an S3 bucket (technically it's a Digital Ocean Spaces bucket). Here's what I do: $ find . -type f -name '*.css' | xargs -I{...
0
votes
1answer
41 views

Can't remove commas in filenames on Linux

I have folder named 'data' in the terminal folder. Some of the file names in data have a ',' in them. I am able to list them by $ cd data $ ls -i |grep -E '\,' But I don't know how to remove ',' ...
1
vote
1answer
31 views

how to rename a number of files using wildcard as prefix

Assume I have many files names something like: foo_192.168.1.1.sh bar_192.168.1.1.sh baz_192.168.1.1.sh qux_192.168.1.1.sh and I want to rename them all to foo_192.168.1.100.sh bar_192.168.1.100....
0
votes
1answer
59 views

How to rename a file with different name? [closed]

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
51 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
56 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
25 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
24 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
59 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
45 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
33 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
2k 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
vote
1answer
28 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
60 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
25 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
23 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
113 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
42 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
176 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
51 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
122 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
57 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
56 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
53 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
143 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
133 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
88 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
97 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
199 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
51 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
222 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
94 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
647 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
24 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
77 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
35 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
117 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. ...