Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Need some help with unix commandline

2 posts in this topic

Recommended Posts

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

cd ~/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]
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.


cd ~/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;
ren `x$`.jpg x$`date (mm,dd,yy,hh,min,(am/pm)).jpg


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



Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.