Hello Craig,
On 5/3/17, Craig Sanders via luv-main <[email protected]> wrote:
> On Mon, May 01, 2017 at 10:19:02PM +1000, David wrote:
>> I recommend the perl rename tool. On debian you would install this
>> package:
>> https://packages.debian.org/jessie/rename
>
> i second this recommendation. the perl rename utility is great. bulk
> rename via regular expression.....or ANY perl code fragment that returns
> a replacement filename.
Have looked for rename, and it is there, and it is a Debian system,
although not the current one, as per prior comments about reasonable
pricing of Internet plans. What is available rurally is in no way up
to the standards of the cities, even rural cities.
> It's basically a big loop around the perl File::Rename module.
> /usr/bin/rename feeds filenames into whatever script you give it and if
> the filename is returned changed, it renames that filename to whatever
> the returned name. if return is empty or unchanged, it doesn't get
> renamed.
>
> Most rename scripts you'll write are just one or more 's/search/replace/'
> one-liner statements, but they can be a quite complicated perl script if
> required.
I need to learn perl, but will do a lot better around other people,
which is not so easy when in a rural area with less population and an
excess of Windows and mac users who have no interest in more than
using the bare minimum of provided utilities.
> BTW, on non-debian systems, an old version of this rename utility is
> sometimes called 'prename'. Newer versions may be called 'file-rename'.
>
> NOTE: there is another renaming utility around called 'rename' but it is
> NOT this perl rename tool and has completely different and incompatible
> behaviour and command line options. can't remember the details right now
> but you can check that you have the right rename installed if you get
> output like this:
>
> $ rename --version
> /usr/bin/rename using File::Rename version 0.20
>
> or check 'man rename' - if it mentions perl, it's good.
That reported perl, but the --version option is not supported on the
rename on this install.
>> Your specification is mostly clear but does contains some ambiguity,
>> for example:
>> - "brackets", are they () or [] or {} ?
>> - what "sequence number" does the second photo have?
>> - is the "sequence number" inside a pair of brackets?
>>
>> To avoid this game of questions, it would help if you provide actual
>> examples of the various before and after filenames, so that anyone
>> tempted to offer any solution can see and test exactly the names you
>> have, and want.
>
> agree with this too.
I did try to describe reasonably, but as usual, a bit tired. Here is a
sample from ls -l
-rw-r--r-- 1 markt markt 197598 Mar 1 04:06 01032017(001).jpg
-rw-r--r-- 1 markt markt 214318 Mar 1 04:06 01032017(002).jpg
-rw-r--r-- 1 markt markt 190798 Mar 1 04:06 01032017(003).jpg
-rw-r--r-- 1 markt markt 228596 Mar 1 04:06 01032017.jpg
-rw-r--r-- 1 markt markt 309380 Jun 30 2014 01072014.jpg
-rw-r--r-- 1 markt markt 387864 Aug 1 2015 01082015(001).jpg
-rw-r--r-- 1 markt markt 366810 Aug 1 2015 01082015.jpg
-rw-r--r-- 1 markt markt 283679 Feb 2 2015 02022015(001).jpg
-rw-r--r-- 1 markt markt 254936 Feb 2 2015 02022015.jpg
-rw-r--r-- 1 markt markt 170619 Mar 2 2011 02032011(001).jpg
-rw-r--r-- 1 markt markt 147527 Mar 2 2011 02032011.jpg
-rw-r--r-- 1 markt markt 433349 Apr 2 01:43 02042017(001).jpg
-rw-r--r-- 1 markt markt 295149 Apr 2 01:43 02042017.jpg
-rw-r--r-- 1 markt markt 368830 May 1 2011 02052011(001).jpg
-rw-r--r-- 1 markt markt 361488 May 1 2011 02052011(002).jpg
-rw-r--r-- 1 markt markt 375954 May 1 2011 02052011.jpg
-rw-r--r-- 1 markt markt 253339 Sep 2 2010 02092010(001).jpg
-rw-r--r-- 1 markt markt 272784 Sep 2 2010 02092010(002).jpg
-rw-r--r-- 1 markt markt 140074 Sep 2 2010 02092010.jpg
-rw-r--r-- 1 markt markt 356005 Nov 2 2010 02112010(001).jpg
-rw-r--r-- 1 markt markt 372653 Nov 2 2010 02112010(002).jpg
-rw-r--r-- 1 markt markt 261336 Nov 2 2010 02112010(003).jpg
-rw-r--r-- 1 markt markt 320558 Nov 2 2010 02112010(004).jpg
-rw-r--r-- 1 markt markt 308636 Nov 2 2010 02112010(005).jpg
-rw-r--r-- 1 markt markt 302521 Nov 2 2010 02112010(006).jpg
-rw-r--r-- 1 markt markt 310205 Nov 2 2010 02112010(007).jpg
-rw-r--r-- 1 markt markt 227692 Nov 2 2010 02112010(008).jpg
> but in the meantime, try something like this to start with:
>
>
> # DD MM YYYY (nnn)
>
> rename -n 's/(\d\d)(\d\d)(\d{4})\./$3-$2-$1(000)./;
> s/(\d\d)(\d\d)(\d{4})(\(\d{3}\))\./$3-$2-$1$4./;
> ' *.jpg
>
> As the comment line tries to show, the first s/// statement matches and
> replaces filenames WITHOUT the 3-digit sequence (and adds a sequence of
> "(000)"). The second matches filenames WITH them.
>
> This will replace both kinds of filenames іn one operation and neither
> of them will return a replacement filename when they don't match.
I think I can start to follow what you are doing, and I need to be
careful, In typing emails and the like, I am hitting extra keys
unintentionally, I was very familiar with the old IBM keyboards, the
ones with a wedge connector and that could have a cable with an AT or
PS/2 connector, but I have yet to find an adaptor from AT/PS/2 to USB
that I can rely on. I have seen a USB mouse with adaptor to PS/2, but
not for a keyboard, yet. Having a second keyboard on a laptop would be
"interesting"
> Note the '-n' option. That's a dry-run option for testing...from the
> rename man page:
>
> -n, -nono No action: print names of files to be renamed, but don't
> rename.
>
>
> If a test run does what you want, run it without '-n'. Or with '-v' for
> verbose output as it renames your files.
>
> If it doesn't do what you want, play with the regexps until it does and
> REMEMBER to check that you are using the '-n' option before hitting
> enter.
I have the O'Reilly book on regexps, and need to do a lot of study. I
am coping less well as there is a lot else to cope with at the moment.
> Also, it's *always* a good idea to test with a copy of a small but
> representative subset of your files in a different subdirectory before
> doing something irreversible to the originals....if you mess up, it's no
> big deal, just delete the mess and copy them again.
The original photos are still all on the phone, which has limited
storage. I have not deleted any, yet, and will not do so until I am
certain that it will all go as I wish to.
> craig
Regards,
Mark Trickett
_______________________________________________
luv-main mailing list
[email protected]
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main