Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-14-2009, 05:13 PM   #1
Registered: Jul 2005
Posts: 335

Rep: Reputation: Disabled
Opening and saving an image file in a bash script

I've recently moved many image files from an old external drive to a new install, but ls and hsetroot are ignoring these files as actual images (ls doesn't color them properly, and hsetroot says they are bad files). I'd like to try and resave these files instead of having to go through and redownload them. Is there any way to do this using bash?
Old 06-14-2009, 05:45 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
What does 'ls -l ' say about their size, what does 'file' say
about their content/type?

Old 06-14-2009, 10:35 PM   #3
Registered: Jul 2005
Posts: 335

Original Poster
Rep: Reputation: Disabled
ls -sh (easier for me to read) gives 496k for size, and file gives idential output to a known good jpg, minus a comment.

I'm going to make a checksum of the file and compare it to the last known-good version.
Old 06-15-2009, 12:16 PM   #4
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
AFAIK, lscolors bases the color used on the filename extension of the file. Unless your ls uses another method to display colors, you should be able to fix the colors use by modifying $LSCOLORS (and you can modify the script that sets $LSCOLORS, to make it permanent).
I don't know about what hsetroot is/does. When you moved/copied the files from the external drive, do you know what kind of filesystem they were on? My speculation is that they were on a DOS or DOS-like filesystem, which used only upper case filenames. On my installation, lscolors only knows about the lower-case filename extensions. If your file names are all uppercase, perhaps it would be appropriate to rename them to more Unix conventional names, especially the extension part.

--- rod.
Old 06-15-2009, 03:27 PM   #5
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46

what does identify (from the ImageMagick package) or gm identify (from the GraphicsMagick package) say about the files?

Old 06-16-2009, 01:23 PM   #6
Registered: Jul 2005
Posts: 335

Original Poster
Rep: Reputation: Disabled
I found out what the problem was: permissions. I had everything set to -rw-r----- instead of -rwxr-----. I changed it, and its working fine now.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a nautilus via a bash cron script rose_bud4201 Programming 3 06-20-2008 09:26 AM
SUSE10.1 : bash query : saving input to file linuxFNG Linux - Newbie 3 03-07-2008 12:23 PM
Bash script to sort image files dtcs Programming 5 09-26-2006 09:50 PM
opening new bash tabs or consoles from a script Nice-n-Slow Programming 7 07-12-2004 09:25 AM
Image Comparison With Bash Script smcallis Programming 4 06-30-2004 12:53 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:36 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration