Jump to content

Need some help with unix commandline

  • Please log in to reply
1 reply to this topic



    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 219 posts
  • Gender:Male
  • Location:Los Angeles
used to do this in windowz and well my main doesn't run windowz anymore at least not 24/7 lol. Here's the deal

I started like this in code
#!/bin/shcd ~/Documents/pictures/wget [url="http://thiswebsite.com/pictures/pic1.jpg"]http://thiswebsite.com/pictures/pic1.jpg[/url]wget [url="http://thiswebsite.com/pictures/pic2.jpg"]http://thiswebsite.com/pictures/pic2.jpg[/url]wget [url="http://thiswebsite.com/pictures/pic3.jpg"]http://thiswebsite.com/pictures/pic3.jpg[/url]etc......wget [url="http://thiswebsite.com/pictures/pic17.jpg"]http://thiswebsite.com/pictures/pic17.jpg[/url]
I once upon a time wrote a script that actually did exactly what I wanted to do namely not just download the 17 pictures that change every so often but append the name to reflect the date and time downloaded as well as preserve the original filename part. since I dun remember the syntax I'll have to write mock code and hope you guys can help me out.

echo=offcd ~/Documents/pictures/For x$=(pic1,pic2,pic3,pic4,........,pic17)do wget [url="http://thiswebsite.com/pictures/`x$`.jpg;"]http://thiswebsite.com/pictures/`x$`.jpg;[/url] call rename;doneRenameren `x$`.jpg x$`date (mm,dd,yy,hh,min,(am/pm)).jpgreturnend

I googled on the web about appending filenames but everyone I read just showed examples of the date, also I'mma not sure if you can do in darwin the for do done loop with a call to a subroutine embedded like this.
:( so honestly I am throughly confused. and need some help.
renaming the files manually would take forever and would be a pain.
this would be the best solution if someone can help translate my mock code into unix commandline



    InsanelyMac Protégé

  • Members
  • Pip
  • 17 posts
I *think* it can be done like this:

		 declare -a PICS=('pic1' 'pic2' 'pic3' 'pic4');
		 for x in ${PICS[@]}; do
		   wget "http://thiswebsite.com/pictures/$x.jpg"
		   mv "$x.jpg" "$x-`date +"%m-%d-%y_%H:%M%p"`.jpg

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy