You are not logged in.

#1 2010-11-01 10:55:40

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

Command line question,

Hi all,

I am using googlecl to upload a bunch of picture to my picasa account, so far no issue.

But if i'm using ~/picasa-upload/*.JPG it will upload all but in a random order.

see outcome below:

Loading file /home/sweetth/picasa-upload/SDC10825.JPG to album Newcastle
Loading file /home/sweetth/picasa-upload/SDC10809.JPG to album Newcastle
Loading file /home/sweetth/picasa-upload/SDC10740.JPG to album Newcastle
Loading file /home/sweetth/picasa-upload/SDC10781.JPG to album Newcastle

I want to have them to upload from SDC10655.JPG to SDC10800.JPG

is there a way to right the commands to do have the upload happening in numerical order?

Many thanks,

Offline

#2 2010-11-01 11:22:18

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: Command line question,

Maybe you could do something like

ls *.JPG | xargs googlecl additionalparameters

ls will list sorted by name by default, and xargs will build an argument list
by data received on stdin (in this case the output of ls)

You should check out the xargs manpage, but to help any more we need to
know the full parameter list (of course sumstitute password for dummy data
etc.)

Last edited by tlvb (2010-11-01 11:23:52)


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

#3 2010-11-01 11:27:51

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: Command line question,

maybe kind of sort could help too.

ls *.JPG | sort | xargs googlecl additionalparameters

Offline

#4 2010-11-01 12:09:25

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Command line question,

Don't parse ls, it is bad.

Last edited by Mr.Elendig (2010-11-01 12:11:57)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2010-11-01 12:17:28

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: Command line question,

without any reason?

Offline

#6 2010-11-01 12:27:37

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Command line question,

Slower and more error prone.

If you want to sort the filenames using sort, someting like `printf '%s\n' * | sort -r` can be 2x faster then `ls | sort -r`

But as a different note. globbing in bash is sorted alphabetically, so you could simply use a for loop instead to get them uploaded in order.
The upload script you are using might not have an internal ordering, but a for loop would negate that.

Edit: stupid internet keeps hanging and messing up my posting sad

Last edited by Mr.Elendig (2010-11-01 12:56:40)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#7 2010-11-01 12:53:26

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: Command line question,

Allthough ls works ok here, parsing ls output is a bad habit in general because a) the output will differ across implementations, b)  it will cause problems if it's used in a for loop like this, and c) it is often not necessary at all...

Just loop over a glob in bash:

for f in *.JPG; do googlecl "$f"; done

(this will call googlecl for each file individually, not sure if that's what you want)

Or use find and xargs instead of ls:

find . -name '*.JPG' -print0 | xargs -0 googlecl

Last edited by hbekel (2010-11-01 12:58:38)

Offline

#8 2010-11-01 13:52:38

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Command line question,

If you're not uploading *.JPG, here's how you glob the range you've given as an example - just substitute it into the commands above.

SDC10@(6[5-9][5-9]|7[0-9][0-9]|800).JPG

test it with:

ls SDC10@(6[5-9][5-9]|7[0-9][0-9]|800).JPG

before doing anything substantial.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#9 2010-11-01 14:27:56

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Command line question,

hbekel wrote:
find . -name '*.JPG' -print0 | xargs -0 googlecl

boo to extraneous processes ;P

find . -name '*.JPG' -exec googlecl {} \+

note the \+ vs the usual \;

find also accepts -regex if you want to get fancy with skanky's stuff too.

Offline

#10 2010-11-01 19:46:34

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

Re: Command line question,

Right,

It is actually easier, rather than calling the google script then telling what to do.

If I launch "google picasa post --title Newcastle ~/picasa-upload/*.JPG"

They will be upload in order....

Why make it so complicated when it's simple...

Offline

#11 2010-11-02 14:15:15

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: Command line question,

brisbin33 wrote:
hbekel wrote:
find . -name '*.JPG' -print0 | xargs -0 googlecl

boo to extraneous processes ;P

Guilty tongue I wasn't aware of  -exec ... {} \+, thanks for the tip!

Offline

Board footer

Powered by FluxBB