Showing posts with label filehandling. Show all posts
Showing posts with label filehandling. Show all posts

Tuesday, 17 November 2009

Howto: Stop Ubuntu 9.10 Karmic Mounting USB Devices With UUID Instead of a Name

Ubuntu 9.10 Karmic Koala changed the way USB devices get mounted a little bit. Instead of being mounted as /media/disk and then each other device becoming /media/disk-1, disk-2 and so forth, now the device is mounted with its UUID, a seemingly random string.

I never minded the disk-1, disk2 thing, though it was slightly annoying to not know which device was which sometimes it was seldom a problem as I had frequently just plugged it in and watched it mount. So the new change was a bt more of an annoyance as its harder to see which random string just appeared sometimes.

The solution as ever is pretty darned simple however, just label the device you lazy bum ;)

Pop along to the following page and read how to label different partition types, most likely fat16/32 or NTFS for your average thumbdrive of phone/mp3 player mounted as a mass storage.

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

Personally I use the Gparted method as mtools has an issue which means you have to add the device to a config file first (its detailed on the page) and while its not hard, its just an extra step I don't need.

So if you don't have Gparted installed already do the following or use Synaptic:

sudo apt-get install gparted

Start Gparted from the System/Administration menu, then select your device from the drop down list in the top right then unmount it by right clicking it in the lower frame and choose unmount. This is so you can make changes to it. Choose to "label" it from the same right click menu or from the Partition menu, finally you have to apply the changes by clicking the right most icon on the toolbar to "Apply all changes". It is done instantly and no longer will that device be known as /media/4169-87bb.

Wednesday, 5 August 2009

Howto Create Split RAR Files

Lets learn how to create split Rar files

If you have a large amount of data to backup or especially to transfer it can be very prudent to use an archive that can be split into smaller parts, if one section becomes corrupted during transfer, it is far better to transfer a single 15mb file again, than an entire 10GB file, right?

Lets grab the rar program:

sudo apt-get install rar

Ok lets compress our directory of files:

To compress file(s) to split rar archive know which directory you want to compress, I'll use a fictional DVD Image folder in the home folder.

rar a -m5 -v5M -R myarchive /home/yourname/dvdimage

Let me break the above command down

rar – starts the program
a – tells program to add files to the archive
-m5 – determine the compression level (0-store (fast)…3-default…5-maximum(slow))
-v15M – determine the size of each file in split archive, in this example you get files with size 15MB (if you wanted files of 512kB size you would write -v512k)
myarchive – name of the archive you are creating
/home/yourname/dvdimage – is folder of the files you wish to add to the archive

You can also add -p to the command after a and it will prompt you for a password.

You can read the manual for more options with man rar (Press q to exit and arrows to scroll up/down)

To uncompress the archive type:

rar x myarchive.part01.rar

Or right click on file myarchive.part01.rar in Nautilus and choose Extract Here.




Friday, 29 May 2009

Is your Nautilus slow to open directories?

Fix Naultilus slow loading some directories.

If nautilus is taking an age to load some directories on your computer then you may have Assistive Technologies enabled.

Simply go to the System menu on your desktop and then in Preferences. Click on Assistive Technologies.
Untick the box marked "Enable Assistive Technologies" and choose "Close and Log Out" at the bottom of the window.

When you log back in Nautilus should be opening directories instantly again. Apparently this became an issue in 8.10 when Assistive technologies was enabled by default, I only spent aoround 8 months suffering with this before getting off my backside and finding a fix, it is disappointing that there has not been a direct update to sort this out, there must be a lot of people stuck with this problem.

Saturday, 30 August 2008

Use rsync to and from copy files from a remote machine

Assuming the remote machine has SSH successfully installed and working then it is a simple case:

rsync -v -u -a --delete --rsh=ssh --stats username@192.168.0.100:/home/username/remotefile.txt

This will copy files from /home/username/remotefile.txt on the machine at 192.168.0.100

to copy files to that same machine then the command syntax is as follows:

rsync -v -u -a --delete --rsh=ssh --stats localfile.txt username@192.168.0.100:/home/username/

I will do a more in depth backup write up using rsync soon.

Friday, 22 August 2008

Recurse to find files and move them to a location

I just had to move a bunch of files out of individual sub-folders into the parent folder, time consuming to do that 50 or so times so a quick check of the "find" command and the solution is here:

find . -iname '*.avi' -exec mv {} /home/subbass \;

Command breakdown looks like this:

find .
find "here"
-iname '*.avi'
case insensitive name match on *.avi
-exec mv
execute the move command on the matches
{}
the match result from find
/home/subbass/
path to move the files to
\;
end of the -exec, each match runs as a new command

A quick command line, fairly simple syntax and it should prove a great time saver. You could easier of course cp or rm files instead of mv or many other possibilities.

Thursday, 14 August 2008

Use convert to add a border to multiple images in the command line

Ok, so you you have taken a bunch of photos with your new camera and what do you know, some of them are half decent. I use this after I have copied photo's I want to print or photo's that I am sending to flickr or deviant art to a seperate folder as it really adds a finishing touch, I copy them to a seperate location so I know exactly which ones I am printing/uploading and don't omit any.

Now you could easily do this in The Gimp, load each image and enlarge the canvas followed by a fill and then resave the image. This is linux though and we can do things a heap simpler than that!
First install Imagemagick:

sudo apt-get install imagemagick


Or install it via Synaptic or your package manager.

Then use this simple script,

be aware that you should operate on copies as this does overwrite the original, as noted above I only do this on photo's I have copied for printing/uploading.


for img in `ls *.jpg`

do
convert -bordercolor white -border 50x50 $img $img
done

Easiest to pop it all into a bash script, or just close it up separating the commands with semicolons into a one liner eg.

for img in `ls *.jpg` ; do ; convert -bordercolor white -border 50x50 $img $img ; done

If your camera uses a different extension then adjust the .jpg accordingly.

Adjust "50x50" to whatever you feel adds a nicely sized border, and feel free to change the border colour (black for instance). If you want to get creative stack up the converts to add a thin black border before a larger white border or whatever you fancy.