The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Copy and rename files recursively (http://hintsforums.macworld.com/showthread.php?t=110944)

DeltaMac 04-23-2010 10:54 PM

Just curious - will this DVD - and all its complex file structure - copy more easily from a PC using Windows? Or will Windows also have problems getting a complete copy in the way that you need it...

I'm also curious - what sort of PC do you have, in this modern era, without the capability to read a DVD data disk.

sojourner 04-24-2010 01:40 AM

Actually, at one point, we did put the DVD on another Windows machine and tried copying files that way. The errors were legion. I got about 10 errors, each stopping the process, before I gave up and looked for another way to get this done.

Brett, I've already left work, so I'll have to give that tar command a shot later.

sojourner 04-24-2010 01:43 AM

If I'm going to copy this tarball over to Windows, I need to rename the files before putting them in the tar. The long file names do not work in Windows.

I apologize, I'm reading what I said earlier, and I have not been clear. It's been a long day.

File names past a certain length do not work in Windows.

brettgrant99 04-24-2010 10:27 AM

How was the DVD created? I made the assumption that it had been created on a windows machine.

Are you trying to put it on old hardware/software like onto a window95 box?

Does it puke at the filename, or the combination of the path+filename? The examples that you gave are not that long. I don't know about the 'special' characters though. On one of the files that it gives you an error, how many characters are in the full path + filename, including spaces?

Another possibility is that the DVD may be bad.

It worries me that a good windows box cannot handle the DVD.

Can you be more specific with what the errors were, if there were only 10 of them, and which machine generated them.

Also, which machine is the samba server and which one is the client?

Brett

sojourner 04-24-2010 03:37 PM

I used find last night to create a text file containing a list of all the files and subfolders. I also tinkered with an Automator workflow to do the renaming and copying. The test version went well. I've got a little more tinkering to do, but it looks it will work.

Brett, don't know how the DVD was created. Using Windows XP. Windows doesn't seem to like exceptionally long filenames. I don't remember the magic number, but 50 was well below the number. One of the error-producing filenames is 89 characters in length.

I don't know if the DVD was bad. Is there such a thing as a good Windows box?

For the error-producing files, I get an error message which says something like 'unable to open file'.

Unsure that I know what you mean by 'which machine is the samba server'. I don't have access to the server; that's IT's department.

brettgrant99 04-24-2010 06:09 PM

Well, as long as you have something that you will think work.

What you say, doesn't really make sense, though. If a windows box isn't happy with a 50 character filename, how did it create files with 50+ characters?

The client is the box requesting service, the server is the box giving, well, service. If you IT department is providing a Network Drive, and your local desktop connects to it, you desktop is the client.

Let us know how it goes.
Brett

sojourner 04-24-2010 06:26 PM

Quote:

Originally Posted by brettgrant99 (Post 580352)
...What you say, doesn't really make sense, though. If a windows box isn't happy with a 50 character filename, how did it create files with 50+ characters?

Yeah, that part boggles my mind, really. I don't understand how that's possible.

I'm working on the client machine, then.

DeltaMac 04-25-2010 07:25 AM

sojourner - Is this DVD a commercial disk - which may have that file corruption built-in as a form of copy protection?
What exactly is the DVD? What company produced it?
Maybe the files are supposed to live on the DVD, similar to some games, and the DVD must be in the drive for those files to be accessible.

sojourner 04-25-2010 03:37 PM

It looks like a generic DVD. I don't see a name on it or anything.

DeltaMac 04-25-2010 04:09 PM

The disk didn't magically appear - or did it? :D
The disk came from somewhere - what is is the source of the disk?
Is it a disk that you created, or is it a disk that you bought somewhere? - Or an image that you downloaded? Or is it a disk with a customer's files?
If none of those has any answer - can you tell us what those files are used for? Graphics, or a database of some kind? Is there an app on the disk that allows you to use the files?

Reason that I ask - the source and purpose of the files on that disk may help determine why it's so challenging to copy.

OR - maybe the disk is just damaged somehow.

sojourner 04-25-2010 04:54 PM

Quote:

Originally Posted by DeltaMac (Post 580434)
Reason that I ask - the source and purpose of the files on that disk may help determine why it's so challenging to copy.

Tell me more.

DeltaMac 04-25-2010 05:10 PM

"Tell you more" - what?
The disk might have copy protection in some form, or will only be accessible from the DVD.

Did you create the file structure on that disk?
Is there something unusual about the disk file setup, which demands use from that disk only?
Is there an on-disk app that allows use of the files?
what is the ultimate use of the DVD (stock photos, clip art, mailing list, newspaper articles, etc, etc)
You still haven't answered - what is the source of that disk?

sojourner 04-25-2010 05:19 PM

It's a generic disk with files on it that someone gave me.

And since several people (not just you) are very curious as to why Windows refuses to copy, I'm curious as to why people are curious. The geeks in IT were of the opinion that long filenames are something that creates problems in Windows. What experiences makes your opinion differ from IT?

Hal Itosis 04-25-2010 05:24 PM

Has this thread actually started yet?

sojourner 04-25-2010 05:30 PM

My gut says no.

hayne 04-26-2010 09:14 AM

Quote:

Originally Posted by sojourner (Post 580442)
The geeks in IT were of the opinion that long filenames are something that creates problems in Windows. What experiences makes your opinion differ from IT?

http://msdn.microsoft.com/en-us/libr...).aspx#maxpath

sojourner 04-26-2010 04:59 PM

Thanks. That was greek to me, but I'll forward it to IT. Maybe they can make heads or tails of it... when they have time.

sojourner 04-26-2010 05:35 PM

According to the internet, Windows has a problem with file names that are too long.

Is this a hazing ritual?

brettgrant99 04-26-2010 08:14 PM

Everything on the internet is right, right :)

Even this post.

All kidding aside, the links that I saw are referring to names with sharing. I can totally see some weird limiting going on with sharing.

Unfortunately, it still isn't really clear what you are doing. Some of what you have described is clear, and some isn't.

It seems that you work at some company that has an IT department. You don't need to name names. Do you have access (perhaps through the IT dept) to windows boxes with XP, Vista, what ever the shortcut for windows7 is?

Do these machines have local harddrives and can you write to them?

I would look at the copy issue first. Can I create a root level directory (say c:\myData) on the local hard drive? Can I write the data there? If not, can I capture some the errors? If there are multiple errors, are they the same. If I do the same thing on a machine with a different OS, say Vista, do I get the same errors?

Now if I try and do the same thing on a network share, do I get the same issues? What about a location with spaces in the path (like c:\Documents and Settings\username)?

If I didn't have access to all of those different machines, or the answers are always yes, the error message is identical, I would maybe try the same thing on a linux or mac box, again going from DVD to a local drive.

If that works, I would then make a little test directory that contains some files that you know will work on a windows box and one file that you know doesn't work.

I would then play around with tar, rsync, ditto, etc to see what works and what doesn't. If nothing works, I would then start evaluating if more time, read money, is really necessary.

Now, perhaps, it is time to think about ways that might fix the copy issue. Renaming the files is not a bad idea, but what if in directory1 there is:

foo.txt
fooLonger.txt

but in directory2 there are the different files with the same names.

Would you go directory1

foo_1.txt
foo_2.txt

directory2

foo_3.txt
foo_4.txt

and so on. Or would you restart with foo_1.txt in directory2. Are any of the files duplicates?

Can you even access the contents of the files? I would try both before and after the name changes. Perhaps the files are not even readable?

I would start making plans, starting with the very basic and/or simple first, lay out the plan in English (or whatever you native tongue is, just don't use computer jargon), and then figure out how to implement it.

This is where I would start.

Brett

sojourner 05-10-2010 05:13 PM

Code:

global fileExt, appendNumber

try
        with timeout of (3 * days) seconds
                tell application "Finder"
                       
                        set filePath to "Macintosh HD:Users:Shared:Mangiapane - Brown Computer Disk 5:"
                        set fileExt to ".msg"
                       
                        set allTheFiles to entire contents of folder filePath as alias list
                       
                        repeat with thisFile in allTheFiles
                                set thisFileName to name of thisFile
                               
                                if kind of thisFile is not "Folder" then
                                        if length of thisFileName > 49 then
                                                set thisFileNameWithoutExt to characters 1 thru -5 of thisFileName as string
                                                set thisFileNameWithoutExt to characters 1 thru 46 of thisFileNameWithoutExt as string
                                                set thisFileProposedNewName to thisFileNameWithoutExt & fileExt
                                                set containingFolder to container of item thisFile as alias
                                                set appendNumber to 0
                                               
                                                set thisFileProposedNewNameExists to my checkForExistingFile(thisFileProposedNewName, containingFolder)
                                               
                                                repeat until thisFileProposedNewNameExists is false
                                                        set thisFileProposedNewName to my createNewNameForThisFile(thisFileNameWithoutExt)
                                                        set thisFileProposedNewNameExists to my checkForExistingFile(thisFileProposedNewName, containingFolder)
                                                end repeat
                                               
                                                set name of thisFile to thisFileProposedNewName
                                        end if
                                end if
                        end repeat
                end tell
        end timeout
on error errMsg number errNum
        do shell script "/usr/local/bin/growlnotify -s -t error -m " & quoted form of ((errNum as text) & return & errMsg)
end try

on checkForExistingFile(thisFileProposedNewName, containingFolder)
        tell application "Finder"
                if exists item thisFileProposedNewName of containingFolder then
                        set thisFileProposedNewNameExists to true
                else
                        set thisFileProposedNewNameExists to false
                end if
                return thisFileProposedNewNameExists
        end tell
end checkForExistingFile

on createNewNameForThisFile(thisFileNameWithoutExt)
        set appendNumber to appendNumber + 1
        set thisFileProposedNewName to thisFileNameWithoutExt & space & text -2 thru -1 of ("00" & appendNumber) & fileExt
end createNewNameForThisFile



All times are GMT -5. The time now is 05:24 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.