PDA

View Full Version : Ubuntu experts needed!



markusman64ds
06-05-2012, 07:28 PM
Not sure where to put this thread, but it's kind of a technical issue, just not hardware.

A little while ago I made a lot of scans with XSane on Ubuntu. I noticed that whenever you saved a file it would say .jpg or .png at the end (not just on the properties menu). This never happened in Windows Explorer, where it would just show the photo name and not the extension (I only recently changed to Ubuntu), so I proceeded to remove the extensions from the photo names. The photos are still viewable, as Ubuntu knows they are JPEGs, but whenever I try to upload the files to a website, the websites can't tell that they are images.

So I need to find a way to fix this. If there was some program that let you change the file extensions of hundreds of images all at once, that would be cool. I just don't know of any programs like this. Hopefully I don't have to go into each filename and change the extension, cause you know, hundreds of files.

FoxNtd
06-05-2012, 07:47 PM
I noticed that whenever you saved a file it would say .jpg or .png at the end (not just on the properties menu). This never happened in Windows Explorer, where it would just show the photo name and not the extension (I only recently changed to Ubuntu), so I proceeded to remove the extensions from the photo names. The photos are still viewable, as Ubuntu knows they are JPEGs, but whenever I try to upload the files to a website, the websites can't tell that they are images.


Windows Explorer's default behavior is to "hide extensions for known file types" which can, of course, be disabled. *nix type OSes such as Linux don't depend on extensions to determine filetype unlike stupid Windows as they actually read the header of the file to determine what kind of data is really there. You can use the "file" command on the command line to see detailed output about a file's type since the header is truly being read. Why did I say stupid Windows? Because it's one of the oldest security risks/tricks in the book. Change the extension of a file to something else and Windows will believe that file is what the extension says it is. They were too lazy with MIME types and never corrected this issue all these years.

Extensions in Linux are for human-reading convenience. The system really doesn't care. Ever notice that executable binaries do not ever have extensions? They can, it just doesn't mean anything.


So I need to find a way to fix this. If there was some program that let you change the file extensions of hundreds of images all at once, that would be cool. I just don't know of any programs like this. Hopefully I don't have to go into each filename and change the extension, cause you know, hundreds of files.

Use the command line.

EDIT: OK if you're asking the question you probably don't know how to do it. Suppose you have a set of files in a directory that need to have ".jpg" appended to them. Pretty simple to do with this:


for i in `ls *`; do mv $i $i.jpg; done

You might want to replace ls * with something else if you really don't want to do this to every file in that directory. That was an example. :)

FABombjoy
06-05-2012, 07:56 PM
Open the command prompt
Change to the directory with the files
Assuming that you're using bash by default, do this:

for file in ./* ; do mv ${file} ${file}.jpg; done

If you're not using bash, just type "bash" before the above command.

Everything in that directory will get a .jpg extension. If you have mixed PNG and JPG, you may want a fancier solution.

markusman64ds
06-05-2012, 08:04 PM
Open the command prompt
Change to the directory with the files
Assuming that you're using bash by default, do this:

for file in ./* ; do mv ${file} ${file}.jpg; done

If you're not using bash, just type "bash" before the above command.

Everything in that directory will get a .jpg extension. If you have mixed PNG and JPG, you may want a fancier solution.

By command prompt do you mean terminal? And I'm not sure how to switch directories in terminal. Command lines ain't my thing.

markusman64ds
06-05-2012, 08:26 PM
Ok I got it working, but it only changed the filenames with one word in the title.

FoxNtd
06-05-2012, 08:55 PM
Ok I got it working, but it only changed the filenames with one word in the title.

Probably need double-quotes around ${file} so it properly recognizes files that contain spaces. e.g.:


mv "${file}" "${file}.jpg"

FABombjoy
06-05-2012, 09:12 PM
Probably need double-quotes around ${file} so it properly recognizes files that contain spaces. e.g.:


mv "${file}" "${file}.jpg"
Ah, I always forget space handling.

markusman64ds
06-06-2012, 05:28 AM
That worked, but the ones that already had them (the ones with one word) now have two. Ex. Asteroids.jpg.jpg

FoxNtd
06-06-2012, 01:46 PM
That worked, but the ones that already had them (the ones with one word) now have two. Ex. Asteroids.jpg.jpg

Having fun yet? :)


rename .jpg.jpg .jpg *.jpg.jpg

markusman64ds
06-06-2012, 02:08 PM
Got it working, thank you all.

markusman64ds
08-05-2012, 07:52 PM
Having problems instaling Java. I downloaded the Linux version from their website, but I can't figure out how to install it.

FoxNtd
08-05-2012, 11:01 PM
Having problems instaling Java. I downloaded the Linux version from their website, but I can't figure out how to install it.

Any reason why something like this doesn't work?


sudo apt-get install sun-java6-jdk

In any case not only does the Ubuntu community have a forum and support chat on IRC but there are many resources out there where you can quickly find the answer to this. I don't mind helping but the DP forum isn't your best place to seek out help.

Oh, and choose the right package. Maybe you just want the JRE (Java Runtime Environment) instead of the entire SDK (Software Development Kit). :)

markusman64ds
08-06-2012, 08:55 AM
Any reason why something like this doesn't work?


sudo apt-get install sun-java6-jdk

In any case not only does the Ubuntu community have a forum and support chat on IRC but there are many resources out there where you can quickly find the answer to this. I don't mind helping but the DP forum isn't your best place to seek out help.

Oh, and choose the right package. Maybe you just want the JRE (Java Runtime Environment) instead of the entire SDK (Software Development Kit). :)

I typed that into the terminal, and got this:

markusman64ds@markusman64ds-Aspire-5551:~$ sudo apt-get install sun-java6-jdk
[sudo] password for markusman64ds:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate
markusman64ds@markusman64ds-Aspire-5551:~$

Maybe this is the code for an older version. Also I don't really feel like joining another forum if I'll only go on it a few times. Any more suggestions?

FoxNtd
08-06-2012, 12:52 PM
Maybe this is the code for an older version. Also I don't really feel like joining another forum if I'll only go on it a few times. Any more suggestions?

You don't have to join. You just need to look. There's probably 5 copies of every commonly asked question already on there. Also I checked where their IRC channel is.

Server: irc.freenode.net
Channel: #ubuntu

Go to the package manager (Synaptic?) and find XChat. It's a nice IRC client. While you're there, look up Java. I don't see why Java wouldn't be listed there.

The package name I mentioned previously is for a slightly older version of Ubuntu so it doesn't surprise me the package name is outdated. You still didn't say if you need the JDK or JRE. I suspect you're not going to be programming Java so the JRE is what you want. Maybe this is the recent package?



sudo apt-get install oracle-java7-installer

markusman64ds
08-06-2012, 04:30 PM
You don't have to join. You just need to look. There's probably 5 copies of every commonly asked question already on there. Also I checked where their IRC channel is.

Server: irc.freenode.net
Channel: #ubuntu

Go to the package manager (Synaptic?) and find XChat. It's a nice IRC client. While you're there, look up Java. I don't see why Java wouldn't be listed there.

The package name I mentioned previously is for a slightly older version of Ubuntu so it doesn't surprise me the package name is outdated. You still didn't say if you need the JDK or JRE. I suspect you're not going to be programming Java so the JRE is what you want. Maybe this is the recent package?



sudo apt-get install oracle-java7-installer


E: Unable to locate package oracle-java7-installer

Also, I just want the JRE. Gotta play some Minecraft.

FoxNtd
08-06-2012, 04:40 PM
Have a look at this.

https://help.ubuntu.com/community/Java

markusman64ds
08-06-2012, 11:13 PM
Have a look at this.

https://help.ubuntu.com/community/Java

That worked. Thank you!

markusman64ds
09-09-2012, 05:33 PM
I think this is a known issue, but I can't play Minecraft demo mode. I downloaded the launcher, and when I click "Play Demo" it says it is updating, but it never does. Still in Ubuntu. Any ideas? Internet searching isn't showing much.