Jump to content

Linux script for trimming Flickr BBcode


fletch1027
 Share

Recommended Posts

Not sure if this is 100% the right place to post this but this forum looked the closest to the right place. :)

 

I enjoy doing trip reports, and I use Flickr for doing them. However, the BBCode that Flickr spits out includes a lot of things I do not like using: the extra URL link back to my Flickr account and also making the image itself linkable back to my account.

 

This was my process that I grew tired of:

- click on the Flickr uploaded photo, then click the share icon

- copy the BBCode and paste it into a notepad document with a note as to what photo it is

- manually delete all of the URL tags in front of and behind the IMG tags

- go back and write my trip report post and sprinkle in the 6 images per post where they belong

 

This morning I got sick and tired enough of the 3rd step that I wrote a quick and dirty Linux bash script to do this for me (sorry to any Windows guys - but I'm sure it could be re-written in PS if anyone wants to)... ;)

 

 

It takes the original BB Code from Flickr that looks like this (including my little notes above each BB Code):

 

 

31768517650_002cab1755_o.png

 

 

And edits out the URL tags so it now looks like this (photos only w/ no hyperlinks back to Flickr):

 

31768517530_08b79d99b6_o.png

 

(I had to use screenshots so the code wouldn't show the actual photos)

 

 

All I have to do is copy the original stuff into a text file, run the script against it, then copy the output to my trip report.

 

Script is attached if anyone is interested in messing around with it (it originally had a .bash extension but I had to change it to .txt to attach it to this post).

 

It is run from the linux command line like this:

 

[root@centos-harry ~]# ./url-no-tag.sh {your text file}

 

 

 

url-no-tag.txt

Link to comment
Share on other sites

Thanks! I got here by your link from cheapo dad's FOS review.

 

I don't have a Linux machine but I use Windows 10 and believe it or not, I can run Ubuntu Linux on it. I was very surprised to be able to do this, but your post inspired me to check into it. I was aware of cygwin, but I figured I'd try this out.

 

Here is a link for installing the linux command line for you Windows 10 users: http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

 

I ran Harry's bash script on this linux and works great. A couple of tips:

  1. Don't put the BBcode at the very bottom of the file without a new line after it. If you do, you'll loose the last image.
  2. To send the results of the script to another file, use the command line:
    ./url-no-tag.sh infile > outfile 

    (This is pretty obvious for the casual linux user, but added here for the novice.)

Link to comment
Share on other sites

Thanks! I got here by your link from cheapo dad's FOS review.

 

 

 

I don't have a Linux machine but I use Windows 10 and believe it or not, I can run Ubuntu Linux on it. I was very surprised to be able to do this, but your post inspired me to check into it. I was aware of cygwin, but I figured I'd try this out.

 

 

 

Here is a link for installing the linux command line for you Windows 10 users: http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

 

 

 

I ran Harry's bash script on this linux and works great. A couple of tips:

 


  1.  
  2. Don't put the BBcode at the very bottom of the file without a new line after it. If you do, you'll loose the last image.
     
  3. To send the results of the script to another file, use the command line:
    ./url-no-tag.sh infile > outfile 

    (This is pretty obvious for the casual linux user, but added here for the novice.)
     

 

 

 

Glad you liked it. It's funny about cutting off the last IMG because in my original script the last line before the fi was an echo "" but I took it out before uploading the text file because I thought people may not want an extra blank line between the groups of pics so I deleted it. :-)

 

I use a MacBook laptop and have a Parallels vm on it so I created a centOS vm that I can copy and paste the input the output. MacOS is itself a flavor of Linux and I tried my script on it but it doesn't like the Perl call and I haven't had time to troubleshoot it, but it seems to be happy everywhere else...

 

 

 

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

  • Forum Jump
    • Categories
      • Welcome to Cruise Critic
      • ANNOUNCEMENT: Set Sail Beyond the Ordinary with Oceania Cruises
      • ANNOUNCEMENT: The Widest View in the Whole Wide World
      • New Cruisers
      • Cruise Lines “A – O”
      • Cruise Lines “P – Z”
      • River Cruising
      • ROLL CALLS
      • Cruise Critic News & Features
      • Digital Photography & Cruise Technology
      • Special Interest Cruising
      • Cruise Discussion Topics
      • UK Cruising
      • Australia & New Zealand Cruisers
      • Canadian Cruisers
      • North American Homeports
      • Ports of Call
      • Cruise Conversations
×
×
  • Create New...