Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Help with renaming filnames in bulk

ahmiqahmiq Member
edited April 2013 in General

Hi there,
I have been searching for a way to rename file names in my box(not good at making a script) . the scenario is this. I have many zipped files , which have a names like : filename1(ahmiq).zip , filename2(ahmiq).zip , so i wish to rename all those files which have (ahmiq) in them with a _a or something like that e-g , filename1_file.zip , filename2_file.zip.
may be something like If filename matches (ahmiq) , mv it with _file.. If someone could get a few minutes and help me out with it , will be very thankful .

regards

Comments

  • DStroutDStrout Member
    edited April 2013

    Though I don't have much experience with it, the Linux rename command is designed for just such a purpose, and has extensive options with how to select files to rename, and what to rename them to.

  • ahmiqahmiq Member

    @DStrout said: Though I don't have much experience with it, the Linux rename command is designed for just such a purpose, and has extensive options with how to select files to rename, and what to rename them to.

    tx , looking onto it

  • bnmklbnmkl Member
    edited April 2013
    
    for file in *.zip ; do
        mv $file "$( echo $file |  cut -d '(' -f1 )_file.zip"
    done
    
    
  • ahmiqahmiq Member

    @bnmkl said: for file in *.zip ; do

    mv $file "$( echo $file | cut -d '(' -f1 )_file.zip"
    done

    works flawleslly , thanks

  • bnmklbnmkl Member

    image

  • ahmiqahmiq Member

    @bnmkl said: Member

    haha about to watch it :D

  • bnmklbnmkl Member

    Haha.

  • Good now only for future reference, but with the rename command @dstrout mentions you can simply:

    rename 's/(ahmiq)/_file/' *

    which is both less fiddily and more powerful if you can do regex. If you're not confident then -n will allow you to experiment without actually renaming anything :)

  • bnmklbnmkl Member

    image

Sign In or Register to comment.