Index > FileTeePee > File names starting with a space character | |
---|---|
Author/Date | File names starting with a space character |
Richard B 11/05/2009 9:53am | Such names may not be legal but I have some on a Linux host - created by PHP. The relevant files are
[space]dot.txt [space]dot[space].txt The intended file - dot.txt - is also present. I have problems with them: 1. They are listed in iFtp without the leading space 2. Trying to delete one of the wrong files via iFtp actually deleted the correct one 3. I cannot delete the incorrect one (well, I could presumably do so via PHP) 4. Every time I click "List" an additional (duplicate) entry is added to the file list. This only vanishes if I move out of the directory and then back in. |
Richard B 11/05/2009 9:21pm | I've solved my problem using PHP to rename the problem files:
<?php // This *renameselected.php* script is to modify some problem file names // Must be run in the directory to be processed. // Copyright 2009 Nomaz (www.nomaz.co.uk) but may be freely used or modified for all lawful purposes. echo "Rename file names starting with a space<br />"; $dir = opendir(getcwd()); echo $dir . "<br />"; while (($file = readdir($dir)) !== false) { echo "filename: ==" . $file . "== Name length = " . strlen($file) . "<br />"; if (ord($file) == 32) { $filenow = "_SUSPECT_" . $file; rename ($file, $filenow); echo "Renamed to " . $filenow . "<br />"; } } echo (" == All done =="); ?> |
Reply | |