How to truncate filename and foldername

A swapping-ground for Regular Expression syntax

How to truncate filename and foldername

Postby andrewsmith » Thu Aug 21, 2014 12:24 pm

Hello Guys,

My requirement is to truncate filename or folder name which is greater than certain number of characters. How can I achieve this?

I think I need to use regexp, but not sure how, any help is much appreciated.

example:

My file name : 12345678901234567890.txt
Length of my file name(Excluding extension) : 20 characters
Requirements: max length of the file should be 10
End result should be : 1234567890.txt
further description: the process should only keep first 10 characters and remove rest of the characters.


Thanks in advance.

Regards,

Andrew
andrewsmith
 
Posts: 1
Joined: Thu Aug 21, 2014 12:14 pm

Re: How to truncate filename and foldername

Postby Stefan » Thu Aug 21, 2014 2:47 pm

 


FROM:
1234567890ABCDEFGHIJ.ext

TO:
1234567890.ext

RULE:
keep first 10 signs and remove rest of the file name but the extension.

USE:
Remove(5)
From: 11   to: 999


Be sure "Options > Ignore... > File Extensions" is NOT checked.




 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions


cron