Hey guys...

Thanks for the reply.

The rename cmd actually works.  I just screwed it up, and used the
syntax for Debian which is the regex.

For Fed/Centos et al

rename foo cat files  -- works as expected!

Thanks!




On Sat, Feb 24, 2018 at 10:46 AM, Jon LaBadie <jo...@jgcomp.com> wrote:
> On Sat, Feb 24, 2018 at 10:46:46PM +0800, Ed Greshko wrote:
>> On 02/24/18 22:42, Robert P. J. Day wrote:
>> > On Sat, 24 Feb 2018, Ed Greshko wrote:
>> >
>> >> On 02/24/18 22:03, bruce wrote:
>> >>> Hi.
>> >>>
>> >>> Have a bunch of files with the basic naming of:
>> >>> ztcloud_nfs_parseztaa_1__WGS_7500_001__parse.dat
>> >>> ztcloud_nfs_parseztaa_1__WGS_7500_002__parse.dat
>> >>> etc..
>> >>>
>> >>> I'd like to simply remove the 1st part ztcloud_nfs_parsezt from the
>> >>> files, renaming the files to the rest of the filename..
>> >>>
>> >>> Thought it should be simple using rename
>> >>>
>> >>> rename 's/ztcloud_nfs_parseztaa/aa/' zt*.dat
>> >>>
>> >>> However, this didn't work... so.. hmm..
>> >>>
>> >>> How would you guys solve this?
>> >>>
>> >>> SO has a bunch of different solns as well.
>> >> If I understand correctly you want 
>> >> ztcloud_nfs_parseztaa_1__WGS_7500_001__parse.dat
>> >> renamed to aa_1__WGS_7500_001__parse.dat, etc?
>> >> And all the files follow the pattern with the same length?
>> >>
>> >> If so, the simple script
>> >>
>> >> #!/bin/bash
>> >>
>> >> for file in *dat
>> >>
>> >> do
>> >> name=`echo $file | cut -c20-48`
>> >> mv $file $name
>> >> done
>> >>
>> >> does it.
>> >   fedora has a "rename" command that would seem to be designed for
>> > just this sort of thing.
>> >
>>
>> I've not used "rename".  And the OP said what he tried didn't work.  So, you 
>> have the
>> answer or you are just saying you don't like my script?
>>
> The thing I don't like is your script has the potential of
> modifying unintended files.  I'd use one of the shell's
> variable expansion features to strip just what was unwanted.
>
> for f in *.dat
> do
>   echo mv $f ${f/zt...aa/aa}
> done
>
> Fill in the ... with the actual chars.
> The "echo" gives a test run to see what will be done with no echo.
> mv may complain about ",dat" files that don't match the "zt...aa"
> pattern, "original and new name identical.
>
> jon
>>
>> --
>> A motto of mine is: When in doubt, try it out
>>
>
>
>
>
>> _______________________________________________
>> users mailing list -- users@lists.fedoraproject.org
>> To unsubscribe send an email to users-le...@lists.fedoraproject.org
>
>>>> End of included message <<<
>
> --
> Jon H. LaBadie                  jo...@jgcomp.com
> _______________________________________________
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to