LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2009, 07:52 PM   #1
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Rep: Reputation: 32
Post Copy files>


Hi to all .

I have a folder that is around 230GB and need to copy it to an external .


Drive that hold's data = NTFS.
External = Fat32.


when i used the CP command it gives me errors due to the name of ther files in that directory. some files names are just strange and contain special charaters such as & % $ _ , as i remember the error was invalid arguments .

i tried to TAR the file but it stoped at 4GB , with an error "File larger than 4GB " ..

how could i do this.

thanks.
 
Old 04-30-2009, 08:07 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Any current version of Linux should have no problem copying from NTFS to any other filesystem. I suspect that the problem is the special characters.

The general rule is to put the filename in quotes, like so:

cp "/path/funn&#filename" /destination/path/ (Depending on what the special characters are, you might need single quotes.)

You can also "escape" special characters. Suppose you had a file named "fred$dog". If you do:
cp fred$dog /dest/path
the shell will attempt to insert the value of the variable named "dog". To prevent that, do:
cp fred\$dog /dest/path

Personally, I would first rename the offending files. That way, you will not continue to have the same issue. Post some actual example of the "strange" filenames.
 
Old 04-30-2009, 08:14 PM   #3
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by pixellany View Post
Any current version of Linux should have no problem copying from NTFS to any other filesystem. I suspect that the problem is the special characters.

The general rule is to put the filename in quotes, like so:

cp "/path/funn&#filename" /destination/path/ (Depending on what the special characters are, you might need single quotes.)

You can also "escape" special characters. Suppose you had a file named "fred$dog". If you do:
cp fred$dog /dest/path
the shell will attempt to insert the value of the variable named "dog". To prevent that, do:
cp fred\$dog /dest/path

Personally, I would first rename the offending files. That way, you will not continue to have the same issue. Post some actual example of the "strange" filenames.
thank you for the advice . but i tried that.
now check this.

i have a folder named TEST . it has sub-folders and files which are around 400GB or so, you are looking at over 10000 files. i just need to copy the whole folder to an external drive. there should be a way to copy the whole folder .. thankx
 
Old 04-30-2009, 08:17 PM   #4
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by maas187 View Post
thank you for the advice . but i tried that.
now check this.

i have a folder named TEST . it has sub-folders and files which are around 400GB or so, you are looking at over 10000 files. i just need to copy the whole folder to an external drive. there should be a way to copy the whole folder .. thankx
well imagine renaming and editing a 1000 files ? that would take so must time .
 
Old 04-30-2009, 08:20 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
I tried that
What??--I suggested several things.
Quote:
there should be a way to copy the whole folder
Of course!!----cp -R foldername /destination/

The problem is that this command actually means: "find every individual file and copy it." So---special characters will be an issue.
 
Old 04-30-2009, 08:37 PM   #6
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by pixellany View Post
What??--I suggested several things.
Of course!!----cp -R foldername /destination/

The problem is that this command actually means: "find every individual file and copy it." So---special characters will be an issue.
yea i know , is there any other way to get those files , without running into this problem ?

thanks.
 
Old 04-30-2009, 08:58 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,349

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
First thing you need to do is get a list of all the filenames with special chars; something like
Code:
for file in `ls` 
do 
    echo $file |egrep -e '&' -e '@'   # add in all the special chars you need
done
That'll give you a list of all the filenames (with special chars), which you can redirect to a file.
You then need to decide what amendments you want to make and extend the script to do that for you.
 
Old 04-30-2009, 09:10 PM   #8
skipdashu
LQ Newbie
 
Registered: Apr 2009
Location: República de Tejas, Centro
Distribution: Ubunut, Xubuntu, Dotsch/UX
Posts: 19

Rep: Reputation: 0
Did I read the target drive is FAT32... does it have a file size limit or was that FAT16 that had like a 4GB file size limit?
 
Old 04-30-2009, 09:29 PM   #9
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by chrism01 View Post
First thing you need to do is get a list of all the filenames with special chars; something like
Code:
for file in `ls` 
do 
    echo $file |egrep -e '&' -e '@'   # add in all the special chars you need
done
That'll give you a list of all the filenames (with special chars), which you can redirect to a file.
You then need to decide what amendments you want to make and extend the script to do that for you.
thank you very much . But again i wanted something in and out. just like a command that would just copy the whole thing one shot.

thank for the script .

Regards,
MaaS
 
Old 04-30-2009, 09:42 PM   #10
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by chrism01 View Post
First thing you need to do is get a list of all the filenames with special chars; something like
Code:
for file in `ls` 
do 
    echo $file |egrep -e '&' -e '@'   # add in all the special chars you need
done
That'll give you a list of all the filenames (with special chars), which you can redirect to a file.
You then need to decide what amendments you want to make and extend the script to do that for you.
thank you very much . But again i wanted something in and out. just like a command that would just copy the whole thing one shot.

thank for the script .

Regards,
MaaS
 
Old 04-30-2009, 09:55 PM   #11
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Cool

I have another question .

could i use rsync for backup instead of CP ot TAR ? or would it also give errors on special characters or huge files such as 400GB . ???
 
Old 04-30-2009, 10:26 PM   #12
ozminh
Member
 
Registered: Aug 2007
Posts: 73

Rep: Reputation: 19
i run 'dd' when copy a really large partition. then resize it with 'PM', or .....
 
Old 04-30-2009, 10:33 PM   #13
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by ozminh View Post
i run 'dd' when copy a really large partition. then resize it with 'PM', or .....
i tried dd , but dd only copy partitions . dose not copy folder .e.g

dd if=/home/test/data of=/mnt/external ? this wont work .
 
Old 04-30-2009, 10:39 PM   #14
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
But again i wanted something in and out. just like a command that would just copy the whole thing one shot.
I think at least two of us have suggested that was not going to work----and explained why.
 
Old 04-30-2009, 10:43 PM   #15
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by chrism01 View Post
Code:
for file in `ls` 
do 
    echo $file |egrep -e '&' -e '@'   # add in all the special chars you need
done
no need the "ls". its useless and will break on file names with spaces. also no need to call egrep (if using bash)
Code:
for file in *
do
 mv "$file" "${file//[@^&]/}
done
 
  


Reply


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
find files with pattern, then copy those files to another directory ncsuapex Programming 4 08-13-2010 03:38 PM
in copy files or ls files the command want to invert select some files how to?? hocheetiong Linux - Newbie 3 06-27-2008 06:32 AM
How to find files and copy the found files to the floppy in one command justmehere Linux - Newbie 11 05-04-2008 11:29 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
Mepis, copy files to thumb drive, files deleted? vremenno Linux - Newbie 6 09-15-2006 11:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:36 AM.

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