简体   繁体   中英

Adobe Air - AS3 - Listing files in directory without the extension

I'm listing files in the "applicationDirectory" and getting the names with the extension, For example "myVid.mp4". I would like to get only the filename without the extension(mp4)

Here is my code so far

var subjDir:File = File.applicationDirectory.resolvePath("videos");
        var files:Array = subjDir.getDirectoryListing();
        var filesName:Array = new Array();
        for (var i:uint=0; i<files.length;i++)
        {
            trace(files[i].name);
            trace(files[i].nativePath);
            filesName.push({label:files[i].name,fpath:files[i].nativePath});

        }

Thank's in advance!

trace (files[i].name.substr(0, files[i].name.lastIndexOf('.')));

这将删除文件扩展名:

trace(files[i].name.replace(/\.[^\.]*$/,""));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM