Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

number of files in a folder

ls | wc -l #Count files on current directory
ls path/to/dir | wc -l #Count files on specific directory path
Comment

How to count number of files in each directory

du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
Comment

number all files in a folder

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
Comment

number of files of a particular type in a folder

find . -type f | sed 's/.*.//' | sort | uniq -c
Comment

number all files in a folder

ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done 
Comment

PREVIOUS NEXT
Code Example
Shell :: fix shortcut virus cmd 
Shell :: bash iterate over a list 
Shell :: install wine linux 
Shell :: How to check the installed version of React-Native 
Shell :: install phpmyadmin mac 
Shell :: how to install pytorch in conda cpu 
Shell :: turn off selinux centos 
Shell :: zsh: command not found: nslookup 
Shell :: add user to sudoers ubuntu 20.04 
Shell :: docker-compose container list 
Shell :: how to generate ssh key in linux 
Shell :: netlify build command 
Shell :: show saved wifi password windows 11 
Shell :: chmod 777 
Shell :: reset iptables ubuntu 
Shell :: apt install gnome desktop 
Shell :: github desktop for linux 
Shell :: Install Nginx, MariaDB and PHP centos rhel 
Shell :: [ERROR CRI]: container runtime is not running: output: 
Shell :: yarn global package not found 
Shell :: address already in use 0.0.0.0:8080 
Shell :: spec false not working 
Shell :: java check java version 
Shell :: docker no space left on device 
Shell :: changing mac address linux 
Shell :: reactjs capacitor init 
Shell :: clear history centos 
Shell :: powershell join array 
Shell :: install serverless 
Shell :: windows port permission denied 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =