Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

rename files sequentially linux

### Try to use a loop, let, and printf for the padding:
# using the -i flag prevents automatically overwriting existing files, 
# using -- prevents mv from interpreting filenames with dashes as options.

a=1
for i in *.jpg; do
  new=$(printf "%04d.jpg" "$a") #04 pad to length of 4
  mv -i -- "$i" "$new"
  let a=a+1
done

# Here's the same example as a 1-liner:
for i in *.jpg; do new=$(printf "%04d.jpg" "$a"); mv -i -- "$i" "$new"; let a=a+1; done
Comment

PREVIOUS NEXT
Code Example
Shell :: ipnyb to ppt 
Shell :: connect vscode to gitlab 
Shell :: branch conflicts 
Shell :: step to install vue project in visual studio code 
Shell :: git new branch from current 
Shell :: sync gitlab wit github 
Shell :: it is required that your private key files are not accessible by others ubuntu 
Shell :: bash maximum running time 
Shell :: oh-my-posh autosuggestions 
Shell :: check file path linux 
Shell :: windows cmd equivalent of grep 
Shell :: Ansible gather facts with adhoc command 
Shell :: how to rename a file on cmd prompt to current date 
Shell :: git merge local branch 
Shell :: dropbox linux 
Shell :: debian pinning packages 
Shell :: git bash remove files with extension recursively 
Shell :: Reduce brightness below minimum on Ubuntu 
Shell :: bitnami cert 
Shell :: power shell 
Shell :: batch how to check if folder is empty 
Shell :: install heroku cli 
Shell :: how to commit to main branch in git 
Shell :: ubuntu add multiverse 
Shell :: redirect to file 2&1 
Shell :: install powershell 7 
Shell :: Invalid base64-encoded string: number of data characters (221) cannot be 1 more than a multiple of 4 
Shell :: job name getprojectmetadata does not exist 
Shell :: delete missing files from svn 
Shell :: conda install gdal 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =