You can use this to change all files matching the Internet*
pattern to INTxxxxx
$i = 0
foreach ($f in ls Internet*) {
fsutil file setShortName $f ("INT" + $i.ToString("D5") + ".MP3")
$i++
}
You can change ls Internet*
to just ls
to ignore the prefix and rename all files in the folder
$i = 0; foreach ($f in ls *.mp3) { fsutil file setShortName $f ($i.ToString("D8") + ".MP3"); $i++ }
Update:
Unfortunately you can set short names for files on NTFS partitions, as it's the restriction right from the SetFileShortName()
Win32 API
Sets the short name for the specified file. The file must be on an NTFS file system volume.
Therefore the only way you can do for a FAT16/32 partition is rename all your files to a short 8.3 name like this
$i = 0; foreach ($f in ls *.mp3) { mv $f ($i.ToString("D8") + ".MP3"); $i++ }
Of course you can also use the INTxxxxx.MP3
format like above
You can manually hex edit the partition to set the short names and recalculate the checksums but it'll be fragile unless someone writes a tool to automate all those things
Note that names like IN1FAB~1.MP3
or IN64EF~1.MP3
are not random. They're the hash of the file names because it's obvious that the File~NUMBER
pattern doesn't work if there are more than 9 files with that prefix in the folder so something more robust must be used
On all NT versions including Windows 2000 and later, if at least 4 files or folders already exist with the same extension and first 6 characters in their short names, the stripped LFN is instead truncated to the first 2 letters of the basename (or 1 if the basename has only 1 letter), followed by 4 hexadecimal digits derived from an undocumented hash of the filename, followed by a tilde, followed by a single digit, followed by a period .
, followed by the first 3 characters of the extension.
- Example:
TextFile.Mine.txt
becomes TE021F~1.TXT
.
https://en.wikipedia.org/wiki/8.3_filename#VFAT_and_computer-generated_8.3_filenames
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…