Jump to content
Sign in to follow this  
cmlp13

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

Share this post


Link to post
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 :)

Edited by monoceres

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

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...