All Questions
59 questions
0
votes
2
answers
83
views
The loop for file renaming doesn't work right
There are 32 *.dds files in a folder:
pic-0.dds, pic-1.dds, pic-2.dds,...,pic-31.dds
I'd like to rename them to be:
015040.dds, 015041.dds, 015042.dds,...,0150471.dds.
I'm trying to use the ...
4
votes
1
answer
1k
views
Replace all periods with hyphens recursively
To replace all spaces with hyphens, in all files/folders, in all sub-directories, I run the following:
find /path/to/folder -depth -name "* *" -execdir rename 's/ /-/g' "{}" \;
...
-1
votes
1
answer
126
views
Rename numbered files based on a list of corresponding names [closed]
I want to rename my files using a .txt file with proper names
These are my files:
lesson1.mp4
lesson2.mp4
lesson3.mp4
...
This is my txt file with names:
1 Entry to vim
2 Basics of vim
3 Vim motion
.....
0
votes
1
answer
283
views
Bash Script to Recursively Rename Files without changing file extension
I am attempting to rename all files (.jpg,.jpeg,.mov,etc) in parent directory and all subdirectories to date_time_7digitnumber without changing the file extension. The below script accomplishes this ...
0
votes
1
answer
370
views
Rename Files within multiple directories based on partial directory names
I have many directories in a location with files of various extensions within them. The directories follow a standard convention but the files within do not. The solution I'm trying to come to is to ...
0
votes
1
answer
1k
views
Renaming all files in a certain directory and sub directory on MacOS?
I'm trying out the code that answers this questions:
How do I change the extension of multiple files?
I tried this:
# Rename all *.js to *.ts
for f in *.js; do
mv -- "$f" "${f%.js}....
1
vote
1
answer
329
views
Passing argument of a function to exec in find
I would like to define a function to find and replace text in multiple files. I find the command line
find . -type f -exec bash -c 'mv "$1" "${1/<string_to_find>/<...
0
votes
1
answer
175
views
Rename Subdirectories Recursively
I am trying to rename the following directory structure
Tests Directory
├── Test1 Directory
│ ├── 2 - 1. Data
│ ├── 3 - 2. Data
│ ├── 4 - 3. Data
│ ├── 5 - 4. Data
│ ├── 6 - 5. Data
├── ...
0
votes
4
answers
100
views
Renaming in sed to allow further match before substituting
I was trying to rename texts in fileA using sed. The second last column in fileA is where the full description of product names lies. I would like to substitute the product names with its ID. However, ...
0
votes
2
answers
109
views
Rename recursively exluding the current directory
I use this command to rename files recursively:
find -iname \*.bak | rename 's/.bak/.old/'
But I want to exclude the current directory. Example:
.bak
dir1/.bak
dir2/.bak
...
After I want this:
.bak
...
0
votes
1
answer
374
views
How can I rename multiple files within a single directory, to remove the timestamp at the end of the file name?
How can I rename the files below on Linux to remove the time stamp from the file name?
AB_CD_EFGHIKL_20191221_D_1.dat.20191221102446_processed
AB_CD_EFGHIKLMN_20191221_D_1.dat....
0
votes
1
answer
396
views
Renaming 100 files in a directory to new file names stored in a text file
I have a list of 100 files in my working directory
for example
GCF_000021605.1_ASM2160v1_genomic.fa
GCF_001887455.1_ASM188745v1_genomic.fa
GCF_003719755.1_ASM371975v1_genomic.fa
GCF_000021625....
2
votes
1
answer
558
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....
0
votes
2
answers
318
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 number ...
1
vote
2
answers
2k
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.
...