Jump to content

Remove characters from a lot file


Recommended Posts

Is there an auto script that could remove the first four characters from a lot of files? I have 165 files, I need to remove the first four characters which are A number, an number, a period, and a space. For example:

01. File.ext

Can anyone help

Link to comment
Share on other sites

Welcome to the forums :)

Take a look at _FileListToToArray(), the string functions and FileMove() in the helpfile, they should provide everything you need :(

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

No, more like:

#include <File.au3>
$files = _FileListToArray(@ScriptDir)
For $i = 1 To UBound($files) - 1
    FileMove(@ScriptDir & "\" & $files[$i], @ScriptDir & "\" & StringTrimLeft($files[$i], 4))
Next

Ooops, now I actually did the script for him :)

Thanks, worked perfectly! Originally, I had tried to make the file only include the characters I had wanted, but that took out the file extension and left the spaces:

#include<file.au3>

Dim $sourceFolder = @ScriptDir

$Array = _FileListToArray($sourceFolder, "*.*", 1)
For $i=1 To $Array[0]
    $result = StringRegExpReplace($Array[$i], "[^a-zA-Z\ \-_]", " ")
    FileMove($sourceFolder & "\" & $Array[$i], $sourceFolder & "\" & $result)
Next
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...