nwalker78
asked on
file renaming from xxyyyyyyyname to xxyyyyyyy - name
hi, i have several images that are named as a 2letterfollowed by 7 numbers then a descriptive name, i would like to rename them so the id and descriptive name are separated by a " - " example
from an1234567assetimage to an1234567 - assetimage.
if possible id like to integrate this with a current script that iv made so ideally would like to use php if possible if not maybe c#. any advice?
from an1234567assetimage to an1234567 - assetimage.
if possible id like to integrate this with a current script that iv made so ideally would like to use php if possible if not maybe c#. any advice?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thankyou
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Don't do that in PHP, Since you are speaking of C# I assume your PHP run on Windows.
PHP doesn't support UTF16 NTFS name properly, and will only work within the 8 bit code page.
It will work on Linux when using UTF-8 file name,
But file management and renaming on windows will be a disaster.
PHP doesn't support UTF16 NTFS name properly, and will only work within the 8 bit code page.
It will work on Linux when using UTF-8 file name,
But file management and renaming on windows will be a disaster.
I would recommend you do that in Powershell something along those line :
Get-ChildItem "C:\folder" | Where-Object {$_.Name -match "^([a-z]+)(\d{7})(.*)$"} | Rename-Item -NewName { $_.Name -replace "^([a-z]+\d{7})(.*)$" , "$1 - $2" }
I didn't test it...
Get-ChildItem "C:\folder" | Where-Object {$_.Name -match "^([a-z]+)(\d{7})(.*)$"} | Rename-Item -NewName { $_.Name -replace "^([a-z]+\d{7})(.*)$" , "$1 - $2" }
I didn't test it...
Presumably this data is also in a DB, and needs to be updated simultaneously?
ASKER
Hi yes adatabase is involved and in the main the updating of it has been taken careof. Its just that when i changed the naming convention about 3000 images didnt get renamed properly and goin through them one by one got abit tedious lol.
Im not familiar with powershell is that built into windows7?
Thanks for the help
Im not familiar with powershell is that built into windows7?
Thanks for the help
Yes.
ASKER
appologies for the delay been in hospital. and forgot question was still open.
NO prob on delay. hope all is well.
Doc on preg_match