Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: long filenames from windows to mac  (Read 2991 times)

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
long filenames from windows to mac
« on: September 18, 2024, 05:43:37 AM »

i need to transfer 100,000 files with names such as

"qwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnm
qwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqw
ertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwert
zuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzui
opüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiop
üasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüa
sdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasd
fghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnm.aif"


from windows 10 to OS9 / OSX.

the main issue with this is that windows can produce, display and move such file names locally, but when you use .zip, winrar pro or ultraISO in order to move them to them mac, that fails in different flavors.

for some of the files i need to keep their name. but it does not have to the file´s name, it can be any other possible form.

1.)
does anyone has an idea of a windows app which can include such names in image files or archives of any kind (which could be read on OSX, too?)

alternatively:

2.)
does anyone know of a windows utility which could help to bring the filenames into a text document? ideally by drag and drop, that is.

3.)
if you have it within reach: any good utility for windows for making filenames shorter while keeping the extension?
Logged
insert arbitrary signature here

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #1 on: October 20, 2024, 12:18:52 PM »

made my own.
Logged
insert arbitrary signature here

smilesdavis

  • 512 MB
  • *****
  • Posts: 986
  • ...
Re: long filenames from windows to mac
« Reply #2 on: October 20, 2024, 03:15:00 PM »

i just saw this

"better file rename" is the name of the program
Logged
...

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #3 on: October 20, 2024, 05:49:11 PM »

what would that help :P
Logged
insert arbitrary signature here

smilesdavis

  • 512 MB
  • *****
  • Posts: 986
  • ...
Re: long filenames from windows to mac
« Reply #4 on: October 21, 2024, 06:39:54 AM »

Ad 3.)
if you have it within reach: any good utility for windows for making filenames shorter while keeping the extension?

http://www.publicspace.net/windows/BetterFileRename/index.html
Logged
...

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #5 on: October 21, 2024, 09:57:35 AM »

right, i actually asked for this. but of course extracting the original name had to be solved first.
Logged
insert arbitrary signature here

smilesdavis

  • 512 MB
  • *****
  • Posts: 986
  • ...
Re: long filenames from windows to mac
« Reply #6 on: October 21, 2024, 12:27:05 PM »

cant help with that i joined macland at snow leopard :)
Logged
...

V.Yakob

  • 64 MB
  • ****
  • Posts: 105
  • Mac User
Re: long filenames from windows to mac
« Reply #7 on: October 21, 2024, 02:31:12 PM »

To solve the problem of long names in Windows:
Run -> gpedit.msc
Computer Configuration -> Administrative Templates -> System -> FileSystem
Enable template "Enable win32 long path", reboot.

I also added a file with the name: to the archive using the 7zip program:
"qwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfghjklöäyxcvbnmqwertzuiopüasdfg.txt"

And it worked.

To get a list of file names, you can use a simple Powershell script
Code: [Select]
$Path = "C:\Temp"
$Filenames = Get-ChildItem -Path $Path -File
#$Filenames.Name

Add-Content -Value $Filenames.Name -Path C:\Temp\Names.txt -Encoding UTF8

This script will get all files without recursion in the C:\Temp directory and save the names of all files to a new Names.txt file

If you need to make the files shorter, you can also do it with a script on PowerShell on Windows/macOS or AppleScript/bash on macOS, but to do this you need to know the rule by which to rename.

You can come up with many different options, from using part of the current line to the csv file, where the column will have the current name, in another column a new name...

If you tell me -- I'll do it, it's not difficult.
« Last Edit: October 21, 2024, 03:00:55 PM by V.Yakob »
Logged
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #8 on: October 21, 2024, 04:29:39 PM »

7zip is a good idea! (i do not have that installed under windows since winrar pro usually handles it well)

...but how would i look into a 7zip archive under OS9? (looking and seeing the name would be the minimum requirement, it does not have to unarchive.)
 
 
the somewhat arbitrary "auto shortening" which appears when transferring using disk images or zip would not be the main problem - but i may by no means loose the original base names of these files.

so i wrote myself a simple tool which writes these names into a textfile into the same archive via drag-and-drop one of the files in question.
this fits to the problem, as i always have one group of files with the same name inside individual folders already.

the files will be processed programmatically later in OS9 or OSX, so when the filenames are destroyed, i can alternatively at least refer to that textfile, which has the name inside.

i attach the tool (in OS9 version), so that you get a better feeling what this fuzz is all about.
Logged
insert arbitrary signature here

V.Yakob

  • 64 MB
  • ****
  • Posts: 105
  • Mac User
Re: long filenames from windows to mac
« Reply #9 on: October 22, 2024, 02:29:38 AM »

7-zip can use different archive formats, zip is supported.

Here is a script that created copies of files with new names in another directory.
The first 28 characters of the current names will be used as new names.

Code: [Select]
$PathToOrigFiles = "C:\Temp\Orig"
$PathToNewNameFiles = "C:\Temp\Renamed"
$LogFile = "C:\Temp\Log.csv"
$MaxLenghtName = 28 # The number of characters in the file name without extension

$Files = Get-ChildItem -Path $PathToOrigFiles -File

foreach ($File in $Files) {
    # We form a block of variables to manage the file
    $sourceFile = $File.FullName
    $CurrentName = $File.BaseName
    $extension = $File.Extension
    $newName = $CurrentName.Substring(0, [math]::Min($CurrentName.Length, $MaxLenghtName))
    $destinationFile = Join-Path -Path $PathToNewNameFiles -ChildPath "$newName$extension"

    # Copying the file
    Copy-Item -Path $sourceFile -Destination $destinationFile

    # Log the old and new file name in CSV
    $logEntry = [pscustomobject]@{
        CurrentName = $CurrentName
        NewName     = $newName
    }

    $logEntry | Export-Csv $logFile -Encoding UTF8 -Delimiter ";" -Append -NoTypeInformation

}


I did a little testing on empty files with such names -- it works.
The csv file can be opened in excel or numbers to see how it was and how it became.
You can comment on the copy line just to get a log with current and future names.

If the files are in some directory structure, you can also create them automatically. Let me know if it's necessary.
Logged
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #10 on: October 22, 2024, 01:30:56 PM »

i have to try out the different methods in practice and see what will work best.

here is the little "namesaver" which rescues the basename (same basename for all files within one folder) so that it can be read from there later after the names got truncated by a transfer or archieving process.

open app, drag example file onto its window. the resulting text file can be opened with the app itself or any other text editor.

(this is for OS9 - but this is what i currently do under windows.)
Logged
insert arbitrary signature here

V.Yakob

  • 64 MB
  • ****
  • Posts: 105
  • Mac User
Re: long filenames from windows to mac
« Reply #11 on: October 22, 2024, 02:34:37 PM »

I tried my past examples in AppleScript on macOS, and it turned out that it works, everything except POSIX path.

Code: [Select]
set origFolder to alias "macos9:Temp:Orig:"
set LogFile to "macos9:Temp:Log.csv:"

set LogEntry to open for access file LogFile with write permission
write "FileName" & ";\r" to LogEntry

tell application "Finder"
set FilesList to every file of folder origFolder
end tell

repeat with thisFile in FilesList
tell application "Finder"
set FileName to name of thisFile
write (FileName & ";\r") to LogEntry
end tell
end repeat

close access LogEntry
« Last Edit: October 22, 2024, 02:54:17 PM by V.Yakob »
Logged
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.

DrNo7

  • 64 MB
  • ****
  • Posts: 98
Re: long filenames from windows to mac
« Reply #12 on: October 22, 2024, 10:57:24 PM »

Sorry for chiming in late and fuzzy but what about burning them to a CD on windows (with the long names) and leverage the Joliet extension (may not be the exact name) that shows the long name in the comment s of the file and the short name is whatever OS9 compute for the 32 chars ?
Logged
Ti 1 GHz / 1 GB / FW SSD / Airport Extreme PCMCIA (triple boot)
Alu 12 1.5GHz / 1.5 GB / 256 GB mSata SSD (dual boot for now)

V.Yakob

  • 64 MB
  • ****
  • Posts: 105
  • Mac User
Re: long filenames from windows to mac
« Reply #13 on: October 23, 2024, 03:26:17 AM »

I usually prefer to get rid of file names that look like a paragraph of a thick book.
If such files are on Windows, it is logical to do it on Windows, in any case, I would do so, it would be faster.
If it is possible to connect these two computers with an ethernet cable, the easiest way is to transfer over the network using NFS. On Windows, you can install the NFS server via WSL2.
Perhaps IIO has the task of creating a utility for renaming, and therefore the scripts that I published here are not suitable for it.
But once upon a time I used some tool to create a graphical interface for those simple scripts that I wrote. I don't remember what it was called, but maybe it makes sense to look this way.

IMHO, if it's a one-time job, it's easier to use a script and forget about it.
Logged
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #14 on: October 25, 2024, 11:41:10 AM »

it is something i do regulary and needs to be "fixed" on the windows side of things, because i hate to do such things in the windows explorer manually.

burning to a physical media is an interesting idea but i think the names will get cut of just as with deamon tools or powerISO.

my LAN is based on KDX.
« Last Edit: October 25, 2024, 03:59:43 PM by IIO »
Logged
insert arbitrary signature here

V.Yakob

  • 64 MB
  • ****
  • Posts: 105
  • Mac User
Re: long filenames from windows to mac
« Reply #15 on: October 25, 2024, 12:00:05 PM »

The script that I gave you in messages failed to cope with the task of renaming?  :o

In theory, this trick should solve the problem of long names, but not all applications and not all APIs in Windows support it, as it turned out.

Run -> gpedit.msc
Computer Configuration -> Administrative Templates -> System -> FileSystem
Enable template "Enable win32 long path", reboot.

If you have Windows Home, then you need to create a key in the registry
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
Name: LongPathsEnabled
Type:  REG_DWORD
Value: 1

Logged
PPC — PM 8100/80, PM 9600/300, PM G3 Minitower (Rev. C), PM G3 B&W (Rev. B), PM G4 Quicksilver (2002), PM G4 MDD (2003), PM G5 (Late 2005).
Intel — Mac mini (mid 2010), iMac 5k (2017), Mac mini (2018).
AppleSilicon — Mac mini (2020), Mac Studio M2 Max + Apple Studio Display.

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #16 on: October 30, 2024, 10:19:51 PM »

turns out that in windows it is already difficult to move files. :)

when you have like 5000 files in one folder and attempt to move them into subfolders in groups of 100, every 15th time you do that windows copies the files instead of moving them - and the orignals can not be deleted.

when this happens on a PPC mac (which is much, much slower) it is usually enough to close and open the folder and the pheanomen is gone. in windows this is permanent - the files are actually still there.

i need to rethink the whole workflow i am using.
 
 
catching the name in a textfile and transferring them with cut off names works fine.
Logged
insert arbitrary signature here

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4671
  • just a number
Re: long filenames from windows to mac
« Reply #17 on: October 31, 2024, 02:53:17 PM »

ok great, windows managed to destroy half the files. :)
Logged
insert arbitrary signature here
Pages: [1]   Go Up

Recent Topics