Skip to main content
March 25, 2013
Question

Strange Error #2038: File I/O Error

  • March 25, 2013
  • 2 replies
  • 5344 views

Hi

I'm making a simple file renamer, for a bunch of mp3s in a folder.

The code in question is...

var _mySourceAudio:File = File.userDirectory.resolvePath( _sourceMinusExt + _extension );

var pathToNewFile:String = File.applicationDirectory.resolvePath (_location + _extension).nativePath;

var _myDestinationAudio:File = new File (pathToNewFile);

_mySourceAudio.moveTo(_myDestinationAudio, true);

if (_mySourceAudio.exists) trace ('yahoo');// always traces yahoo

Certain files in this folder refuse to change their name (there are no naming conflicts) and throw the 2038 error. Other files are renamed fine when I throw them at the function.

The above code always traces out that the file exists, so the path I'm injecting into it is fine

If I copy the misbehaving files to another folder, and do the edit, they rename fine. Copy this newly renamed file back over the old one in the orignal folder, and back to square one again.

I've spent most of the day debugging this - I'm just wondering if there is something less code related about files that I should be aware of that can cause this?

Cheers guys.

This topic has been closed for replies.

2 replies

sinious
Legend
March 25, 2013

trace() each step of that operation and give an example of a file/folder that's giving you an issue. Make sure you trace _sourceMinusExt + _extension, _location + _extension and your  _myDestinationAudio.nativePath. Paste an example path/file here.

April 4, 2013

Thanks for taking a look guys.

Here's a successful edit (swapping the postions of the title and artist):

_sourceMinusExt + _extension: F:/songs backup/MM00016 - 3 DOORS DOWN - When I'm Gone.mp3

_location + _extension: F:/songs backup/MM00016 - When I'm Gone - 3 DOORS DOWN.mp3

_myDestinationAudio.nativePath: F:\songs backup\MM00016 - When I'm Gone - 3 DOORS DOWN.mp3

and one that throws the #2038: File I/O Error:

_sourceMinusExt + _extension: F:/songs backup/SPC0101 - 3 DOORS DOWN - Kryptonite.mp3

_location + _extension: F:/songs backup/SPC0101 - Kryptonite - 3 DOORS DOWN.mp3

_myDestinationAudio.nativePath: F:\songs backup\SPC0101 - Kryptonite - 3 DOORS DOWN.mp3

And the code again:

var _mySourceAudio:File = File.userDirectory.resolvePath( _sourceMinusExt + _extension );

var pathToNewFile:String = File.applicationDirectory.resolvePath (_location + _extension).nativePath;

var _myDestinationAudio:File = new File (pathToNewFile);

try { _mySourceAudio.moveTo(_myDestinationAudio, true);

sinious
Legend
April 4, 2013

Any reason why the _sourceMinusExt + _extension filename is "MM00016 - 3 DOORS DOWN - When I'm Gone.mp3" but the filename gets flipped (in both examples) for _location + extension like "MM00016 - When I'm gone - 3 DOORS DOWN.mp3"? Both of  your examples flip the artist and song name. I don't see you flipping that in your code. Is something missing?

Inspiring
March 25, 2013

1.Under Windows there are certain hidden file in a lot of folders, you can`t obviously rename your files to one of those.

2.Try to deactivate your antivirus program for the folders for whichyou attempt renaming, some Protections won`t throw an explicit message when surpressing potential threats