Results 1 to 3 of 3
Hello all am not very good at command's or even know it this is posable but am trying to do this "Create folder from a filename and move the file ...
- 02-13-2011 #1
Create folder from a filename and move the file into the folder
Hello all am not very good at command's or even know it this is posable but am trying to do this "Create folder from a filename and move the file into the folder" i have 500000+ file's i need to do with is there a easy way?
I really don't want to download them all make/move them with filemonkey just to re-upload them
Many Thanks
- 02-13-2011 #2Just Joined!
- Join Date
- Mar 2010
- Posts
- 79
You could run a short test like the following, and then look for a better way:
Code:touch {one,two,three}.{sh,txt}Code:#!/usr/bin/env bash for i in "$@" do mkdir ${i}_folder mv $i ${i}_folder done exit 0or:Code:bash move_files.sh *sh
Or both at once:Code:bash move_files.sh *txt
You will need to add several tests:Code:bash move_files.sh *txt *sh
Are arguments given
Make sure the script itself doesn't get moved.
Perhaps let the files get listed, and ask if it is ok to move them
Check for filenames which contain whitepsace.
Check for the exit code of `mkdir`
Perhaps more.
- 02-19-2011 #3
Hey thank's for that
as i know nothing someone made me a bash file which has this in it
It kind of work's tho it split's the filename in to muilty folder'sCode:#!/bin/bash for FILE in `ls | egrep "gif|jpg|png|bmp|jpeg|tif|tiff"` do DIR=`echo $FILE | cut -d '.' -f 1` mkdir $DIR mv $FILE $DIR done
This was my test
fred.jpg
you say whitespace's everyone of my files have them :/ and i also need them for the next part after the folder's are made
Thank's!


Reply With Quote

