Vbscript to rename files and replace special characters
Dear Exprt,
would you please help to add addtional requirement for rename and replace special characters for file
by the below script i can re name.
strAnswer = InputBox("Please enter folder location to rename files:", _
"File rename")
strfilenm = InputBox("Enter name:", _
"Rename Files")
Set FSO = CreateObject("Scripting.FileSystemObject")
Sub visitFolder(folderVar)
For Each fileToRename In folderVar.Files
fileToRename.Name = strfilenm & fileToRename.Name
Next
For Each folderToVisit In folderVar.SubFolders
visitFolder(folderToVisit)
Next
End Sub
If FSO.FolderExists(strAnswer) Then
visitFolder(FSO.getFolder(strAnswer))
End If
[email protected]
Thx would you please look below what wrong in its run nothing happend no error
strAnswer = InputBox("Please enter folder location to rename files:", _
"Test")
strfilenm = InputBox("Enter name:", _
"Rename Files")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set regEx = New RegExp
'Your pattern here
Select Case tmpChar
Case "&"
changeTo = " and "
Case "/"
changeTo = "_"
Case Else
changeTo = " "
End Select
regEx.Pattern = tmpChar
Sub visitFolder(folderVar)
For Each fileToRename In folderVar.Files
fileToRename.Name = strfilenm & fileToRename.Name
fileToRename.Name = regEx.Replace(fileToRename.Name, tmpChar)
Next
For Each folderToVisit In folderVar.SubFolders
visitFolder(folderToVisit)
Next
End Sub
[email protected]
Similar Messages
-
Looking for, and replace special characters
Hi
I am quite new to AppleScript and can't figure this out. Any help would be appreciated.
I have received several (a lot of) folders containing images with some strange characters in the file names. The images has to go to web, and I want to replace those characters with some that are web friendly. The characters in question is some Swedish A's and O's (Ä, ä, Ö, ö) and one that looks like the Apple Command symbol. (I was told this one is a combination of a and e).
Then, I would like to replace all spaces between the words in the file names with an underscore.
In addition, all image file names start with capitals and I would like to replace these as well.
Thanks
Neal
G5 Mac OS X (10.4.6)Here's a modified version of the standard script:
try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
display dialog "Search and replace in:" buttons {"File Names", "Folder Names", "Both"} default button 3
set the search_parameter to the button returned of the result
repeat
display dialog "Enter text to find in the item names:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result
if the search_string is not "" then exit repeat
end repeat
repeat
display dialog "Enter replacement text:" default answer "" buttons {"Cancel", "OK"} default button 2
set the replacement_string to the text returned of the result
if the replacement_string contains ":" then
beep
display dialog "A file or folder name cannot contain a colon (:)." buttons {"Cancel", "OK"} default button 2
else if the replacement_string contains "/" then
beep
display dialog "A file or folder name cannot contain a forward slash (/)." buttons {"Cancel", "OK"} default button 2
else
exit repeat
end if
end repeat
display dialog "Replace “" & the search_string & "” with “" & the replacement_string & "” in every item name?" buttons {"Cancel", "OK"} default button 2
tell application "Finder"
set the item_list to every item of entire contents of source_folder
tell me
set item_list to reverse of the item_list
end tell
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set the_name to name of item i of the item_list
set this_item to item i of the item_list
set this_info to properties of this_item
set the current_name to the_name
set change_flag to false
repeat with this_char from 1 to (count items of search_string)
if the current_name contains item this_char of (search_string) then
if the search_parameter is "Folder Names" and ¬
folder of this_info is true then
set the change_flag to true
else if the search_parameter is "File Names" and ¬
folder of this_info is false then
set the change_flag to true
else if the search_parameter is "Both" then
set the change_flag to true
end if
if the change_flag is true then
set this_item to item i of the item_list
-- replace target string using delimiters
set AppleScript's text item delimiters to the item this_char of search_string
set the textitemlist to every text item of the current_name
set AppleScript's text item delimiters to the item this_char of replacement_string
set the newitemname to the textitemlist as string
set AppleScript's text item delimiters to ""
set the current_name to newitemname
end if
end if
end repeat
my setitem_name(thisitem, current_name)
end repeat
end tell
beep 2
on setitem_name(thisitem, newitemname)
tell application "Finder"
--activate
set the parentcontainerpath to (get the container of this_item) as text
if not (exists item (the parentcontainerpath & newitemname)) then
try
set the name of this_item to newitemname
return this_item
on error the error_message number the error_number
if the error_number is -59 then
set the error_message to "This name contains improper characters, such as a colon (:)."
else --the suggested name is too long
set the error_message to error_message -- "The name is more than 31 characters long."
end if
--beep
tell me to display dialog the error_message default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end try
else --the name already exists
--beep
tell me to display dialog "This name is already taken, please rename." default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end if
end tell
end setitemname
This script variant works by accepting a source string in the form "AB" and desired string "CD". When run, ABCA will become CDCC with the sample strings.
(19254) -
Find and replacing special characters
we have just discovered that after database unicode conversion, some special characters are starting to appear in the database after users copy and paste into the database.
For example from a table, we can identify it with:
SQL> select count(*) from table where column_name like '%' || chr(25) || '%';
COUNT(*)
15
This is for a table.
How can this be done to identify the characters for all tables because we are not sure of all the tables
ThanksHi,
Please try below pl/sql block to identify special characters in tables with respect to columns
set serveroutput on size 1000000
declare
procedure gooey(v_table varchar2, v_column varchar2) is
type t_id is table of number;
type t_dump is table of varchar2(20000);
type t_data is table of varchar2(20000);
l_id t_id;
l_data t_data;
l_dump t_dump;
cursor a is
select distinct column_name
from dba_tab_columns
where table_name = v_table
and data_type = 'VARCHAR2'
and column_name not in ('CUSTOMER_KEY','ADDRESS_KEY');
begin
for x in a loop
l_id := null;
l_data := null;
l_dump := null;
execute immediate 'SELECT ' || v_column || ', ' || x.column_name || ', ' ||
'dump(' || x.column_name || ')'
|| ' FROM ' || v_table
|| ' WHERE RTRIM((LTRIM(REPLACE(TRANSLATE(' || x.column_name ||
',''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%^&*()_+
-=,!\`~{}./?:";''''[ ]'',''A''), ''A'', '''')))) IS NOT NULL'
bulk collect into l_id, l_data, l_dump;
if l_id is not null then
for k in 1..l_id.count loop
dbms_output.put_line(v_table || ' - ' || x.column_name || ' - ' ||
to_char(l_id(k),'999999999999'));
dbms_output.put_line(l_data(k));
dbms_output.put_line(l_dump(k));
dbms_output.put_line('*********************');
end loop;
end if;
end loop;
end gooey;
begin
gooey('table1','coln1');
gooey('table1','coln2');
gooey('table2','coln3');
end;
Like this you can get special characters for all the columns/particular column from table
Thanks,
Nitin -
Pages 5: Find and replace special characters
Has this feature gone? Or can anyone tell me where to find it? I neeed, for example, to replace double paragraph breaks with single ones, how can I do this?
I can't find it either, but the following appears to work:
Turn on Show Invisibles in the View menu.
Select (highlight) the double para breaks.
Use Command-E (Find using selected text).
Open the Find dialogue box (Command-F) and select Find & Replace.The selected para breaks will be in the Find text entry box, but will not be visible!
Click in the Replace text entry box.
Select (highlight) a single para break.
Go to the Edit menu / Find and select 'Use selection for replace' (it will not show in the Replace entry box).
In the Find & Replace dialogue box, click on the Forward or Back arrows to highlight the selected items (e.g. double para break) where you wish to start replacing in the document.
Use the Replace All / Replace & Find / Replace buttons as per usual.
Not a nice solution, but I hope it gets you going until Apple restores the previous functionality! -
Find and Replace Japanese characters in pdf file on iPhone
Hi eveybody !
I want to find and replace Japanese characters in pdf on iPhone.
I using zlib to deflate stream - endstream block and extract text.It's work fine with latin-text.
But when i work with japanese characters , I don't know how to do it ?
I decode a sample japanese pdf file, and I know that each Japanese characters are performances as hex string : "<01b7><0e230a23>..."
But i don't know how to convert Japanese characters to the hex string like that.
Can evrybody help me?
Thanks!Searching is the same process as extracting - since it's about turning page content into something understandable. So that still remains what you need to learn/understand - of course, referring back to all the previous sections about font formats, etc.
Replacing in PDF is EXTREMELY DIFFICULT for two reasons - subset fonts and explicit glyph positioning. Have you determine (conceptually, if nothing else) how you plan to addresses these two issues?
PDF doesn't do UTF8 for page content - so don't worry about that. -
<blockquote>Locking duplicate thread.<br>
Please continue here: [/questions/815207]</blockquote><br>
if i try to download a file with any special characters in file name (e.g. File_Name.pdf), it doesn't reconvert them from the "sanitize url" process and download the file an incorrect name (e.g. File%5FName.pdf).
This is really annoying.
Thank you for your patientStart Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
* Don't make any changes on the Safe mode start window.
* https://support.mozilla.com/kb/Safe+Mode
* [[Troubleshooting extensions and themes]] -
Capturing returns and other special characters
Greetings,
I'm curious to know what is 'normally' done to capture
returns and other special characters from textareas. I want my user
to be able to insert 'control' characters into the text area to
allow them to provide some structure to the information they're
entering. At the moment, I'm processing the text char by char and
working out if it's an 'enter' or whatever, then appending a
'<br />' to the string before I store it and so on.
Is there a more established way to do this sort of
thing?Use the replace function to replace either chr(10) or chr(13)
with a break tag. It's using cold fusion functions to accomplish
the same thing you appear to be doing manually. -
How to replace special characters in string.
Hello,
I want to replace special characters such as , or ; with any other character or " ".I find out there is no such function is java for this.There is only replace() but it accepts only chars.If anybody know how to do this?.
Thanks,Hello,
I want to replace special characters such as , or ;
with any other character or " ".I find out there is no
such function is java for this.There is only replace()
but it accepts only chars.If anybody know how to do
this?.
Thanks,Can't you just do the following?
public class Test
public static void main(String[] args)
String testString = "Hi, there?";
System.out.println(testString.replace(',',' '));
} -
10g won't recognize ellipsis and other special characters.
I'm trying to insert data into both VARCHAR2 and CLOB columns that contains characters such as ellipsis and other special characters. Oracle doesn't recognize the characters and just converts it to garbage. Is there a way to make Oracle easily recognize these characters?
For example, it won't recognize the following ellipsis in the string:
"Here we are … right now."My bad...I did look at the national character set instead.
When I performed theq query you posted, I got the following:
NLS_CHARACTERSET
WE8MSWIN1252
NLS_NCHAR_CHARACTERSET
AL16UTF16
I hope this new information helps. Also, the tool involved is SQL *Plus, but I'm currently concentrated on getting the insert to work via JDBC. Thanks in advance. -
I have set up my work Exchange email/calendar. After setting up I am getting passcode expired message and asking for changing the passcode with a 16 + digit and 4 special characters. No combination of numberic, alphanumeric, special characters is working. Help!!
I have set up my work Exchange email/calendar. After setting up I am getting passcode expired message and asking for changing the passcode with a 16 + digit and 4 special characters. No combination of numberic, alphanumeric, special characters is working. Help!!
-
E72: Swedish and other special characters not work...
When I send mail through MfE, swedish and other special characters do not reach the recipient, they are just ignored. No blanks or nothing. Every word with a swedish character ends up one letter short.
Before the firmware upgrade this was intermittent, happening only on about half of my mails.
Now I upgraded yesterday, and it seems the problem is now permanent.
Have seen similar posts from E75 and E90 owners, their problems seem to have been fixed by newer firmware.
Our setup is: Exchange 2003, Portwise authentication.
All other phone models work fine, like iPhone, E71 etc.
/SebastianAfter some testing I found out that if I use swedish chars in the subject line, it works fine. Even in the mail body.
If I don't use swedish chars in the subject, they won't work in the body. I either get garbage or nothing where the swedish chars should be.
The problem doesn't exist at all in my private IMAP mail account.
Could someone who uses Mail for Exchange and have special chars in their alphabet (swedish, finnish, german, hungarian etc) pls tell me how it's working out for you?
Message Edited by Seb_Martin on 28-Jan-2010 11:15 AM -
Hi,
I want to rename files containg special characters in a directory tree.
For example I want
06\ --\ Doppelgänger.flac
renamed to
06\ --\ Doppelganger.flac
I have found a python script that seems to be able to do it here.
I have also found a list of replacements characters
my $AccentedChars = '€–‚ƒ„…†‡ˆ‰Š‹Œ–Ž––''""•–—˜™š›œ–žŸ'.
'–¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶·¸¹º»¼½¾¿'.
'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß'.
'àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
my $NonAccenChars = 'E-,f,.++^%S_O-Z--````.--~Ts_o-zY'.
'-!cLoYlS`Ca_--R-`+23`uP.,10_qh3_'.
'AAAAAAACEEEEIIIIDNOOOOOxOUUUUYTS'.
'aaaaaaaceeeeiiiidnooooo%ouuuuyty';
from this perl script (which throws an error when used. Otherwise it would be perfect).
So, can somebody tell me how I could feed the python script with the above replacement table?
I have tried but I can't seem to get it to work.
I have also tried to make a simple bash-script using rename but I could not that to work either.
I would really appreciate any help.
Thanks,
RasmusI didn't try the perl script, but sed's y command will do exactly this. tr complains about a dash
accent='€–‚ƒ„…†‡ˆ‰Š‹Œ–Ž––''""•–—˜™š›œ–žŸ–¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
nonaccent='E-,f,.++^%S_O-Z--````.--~Ts_o-zY-!cLoYlS`Ca_--R-`+23`uP.,10_qh3_AAAAAAACEEEEIIIIDNOOOOOxOUUUUYTSaaaaaaaceeeeiiiidnooooo%ouuuuyty'
echo '06\ --\ Doppelgänger.flac' | sed "y/$accent/$nonaccent/"
So you could do something like
for file in *; do
mv -v -i -- "$file" "$(echo "$file" | sed "y/$accent/$nonaccent/")"
done -
Rename files and retain portions of the original filename
I posted a thread about this a while ago, but no solution was given:
http://discussions.info.apple.com/thread.jspa?threadID=2564646
The issue is this: I can't figure out how to rename imported files while also retaining part of the original filename. The images come off of the camera like this:
DSC_3497.nef
I need to do the following:
+- Retain the unique number that the image already has. I don't want to rename the files by date, location, lunar phase, or some other esoteric identifier. I think having a unique ID for each image (one that shows up in standard OS-level searches on both Mac and PC systems) is useful.+
+- Replace "DSC" with the camera model (D3X), since I use multiple cameras with different resolutions and also need to be able to search for images from a certain camera outside of Aperture (i.e. tags/keywords would not help).+
+- Add a digit prior to the four-digit string to indicate the true numeric sequence of the file. Since Nikon cameras reset the number sequence every 10,000 files, I want to indicate the true sequence number directly in the filename. This will also avoid filename overlaps. It also lets me know how many images I've shot with each camera.+
The intended final result would look like this:
D3X_63497.nef
Showing the 63,497th image taken with my D3X.
In Aperture's "File Naming" dialog, I don't see a way to split the existing filename in this way. It looks like I can only append or prepend a Custom Name to the Version/Master name. I don't see a way to split the existing filename at the underscore, for example, so that portions of the original filename can be selectively replaced.
This is not about finding a workable naming scheme for Aperture and then renaming all existing files. I spend time on the PC side for various things and also work with a number of people who don't use Aperture but need access to my image library. I also have hundreds of references to existing filenames in various print and web design projects, as well as my Flickr account with 3000+ photos.
Going back and updating all that stuff is not going to happen. But using a System Service to rename files after every import is also pretty tedious.
Any solutions that meet the three criteria outlined above would be greatly appreciated.sempervirent,
You're asking for some pretty advanced file naming. Most people aren't going to need that sort of function, so I doubt there will be a hook into Aperture to do such a thing. I suggest using a shell script or Applescript along with EXIFTool to rename files before you import them into Aperture. http://www.sno.phy.queensu.ca/~phil/exiftool/
Retain the unique number that the image already has
If you're not afraid of the command line, it's easy enough to use a tool like awk or maybe perl to parse that sequence number from a well-formatted string like the picture name
Replace "DSC" with the camera model (D3X)
You can use EXIFTool to extract the camera model from the EXIF dat ain the photos
Add a digit prior to the four-digit string to indicate the true numeric sequence of the file.
Good luck with this one. You'll have to do a filename search through all of your previous files to find out what 10,000 you're on. It's possible, but you'd have to do some specialized coding in AppleScript or shell script.
nathan -
Replace special characters in FDF
Hello,
I have searched everywhere and cannot find the answer to this simple problem. I can manipulate javascript in an HTML environment by using free scripts, but it's not so easy in a PDF form. I am using Adobe Acrobat 9 Pro and I have a form that when filled out and submitted, generates and emails an FDF file. I am using a server-side script called FormGenie to do this, and the script hates parentheses and some other special characters, they break the FDF file. All I want to do is set up a document level Javascript that will check for and replace all instances of these special characters with something allowed like a hyphen- or just a space.
I have tried:
function clearText() {
document.formname.fieldname.value=filterNum(document.formname.fieldname.value)
function filterNum(str) {
re = /\$|#|~|\%|\*|\^|\(|\)|\+|\=|\[|\]|\[|\}|\{|\;|\"|\<|\>|\?|\||\\|\!|\$/g;
// remove special characters like "$" and "," etc...
return str.replace(re, "-");
and
function clearText2(str) {
stringName = stringName.replace(/\$|#|~|\%|\*|\^|\(|\)|\+|\=|\[|\]|\[|\}|\{|\;|\"|\<|\>|\?|\||\\|\!|\$ /g,'-');
I know these aren't right, but I have to be at least barking up the right tree.
Can someone help?
Thank youOK, here is my first stab at putting together this script from searching the API reference.
To loop through the text fields and get their values, I have:
for ( var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
if ( fname.type = "text" ) f.value; [Not sure if "f.value" is correct or legal here]
If this is even getting close, where I get stuck is how to get the original script to take those values and replace any unwanted characters found.
if (!event.willCommit) {
event.change = event.change.replace(/[\$\#\~\%\*\^\(\)\+\=\[\]\{\}\;\"\<\>\?\|\\\!]/g, "-");
I just need to put this together correctly and I don't know how.
I have the form submission part down, that was already done, I just need to add the custom "Run a javascript" item above it so that is executed first.
Need a little guidance,
Thanks -
Dynamic Images in PDF and Escaping Special Characters
I used the following to create my own PDFs with dymnamic images:
http://marcsewtz.blogspot.com/2012_02_01_archive.html (Dynamic Images in PDF - What 32k Limit? )
I have installed this application on Oracle's free workspace to test.
The issue I am having is that when there is a special character in the description, such as <>'"& then the the PDF will not open. I have tried using the dmbs_xmlgen.convert to convert the description but haven't had any luck.
I'm a complete novice with xml. Any help with this is greatly appreciated.
Thanks,
GlenI have been able to find a solution, but it's not completely perfect. I have changed the "description" field as follows:
XMLCdata(replace(description,''&'',''and'')) description,
The characters greater than (>), less than (<), single qoute('), and double quote (") can now all be in the description and will not cause errors. For some reason, I couldn't get the & not to give an error no matter what I tried, so I just replaced the & with the word "and". This solution will work for my needs, but it would be nice to be able to get the & to display.
Does anyone know of a way to get the & to display correctly?
Thanks again,
Glen
The complete code I am using is below:
declare
l_print_layout clob;
l_xml_data clob;
begin
-- load print layout from database
for c1 in (
select layout from eba_pdfimg_layouts where id = :P1_LAYOUT
) loop
l_print_layout := wwv_flow_utilities.blob_to_clob(c1.layout );
end loop;
-- generate XML data
for c2 in (
select dbms_xmlgen.getxml('
select
id,
file_name,
mime_type,
XMLCdata(replace(description,''&'',''and'')) description,
-- description,
blob2clobase64(image,''Y'') image
from eba_pdfimg_images
') xml_data from dual
) loop
l_xml_data := c2.xml_data;
end loop;
-- download print document
wwv_flow.g_page_text_generated := true;
apex_util.download_print_document (
p_file_name => 'image_demo',
p_content_disposition => 'ATTACHMENT',
p_report_data => l_xml_data ,
p_report_layout => l_print_layout,
p_report_layout_type => 'rtf',
p_document_format => :P1_FORMAT
end;
Maybe you are looking for
-
No sound on YouTube videos and others
I have read through other discussions so I am prepared! I am using Windows XP Prof. PC 32 bit. Hello! I did the checking with the Adobe / Forum website - as to what version I am using in Flash: I was able to get animation - NO Sound I copied this inf
-
I cannot get epson workforce to work correctly on imac mountain lion
I have not been able to get the epson workforce to work on imac mountain lion. I first tried using the epson software. Then read that I should do it from the mac's " printer/scan". Unfortunately when I get to the screen that says --add printer--- i
-
BPM + PROXY + Fault Message
Hello My scenario is JDBC -> BPM <-> Proxy I developed a BPM has a step-type <SENDER> that is synchronous. Information on the above step: . The message interface used an output, an input message and also a Fault Message. . I'm calling a proxy in th
-
hello people! i ve got a problem, my task is to make a program that can be used in the libraries! the main task is that i make a programm which will be an object-oriented database. i have already made this (the object - oriented database program) and
-
Using bean value in NLS text entry
Hi all, Is there a way I can use the JHeadstart NLS function like title="#{nls['HOME_PAGE_TITLE']}" and include a bean value in the title eg " Welcome #{jhsUser.userId} to my wonderful application". I use JHS_TRANSLATIONS to store my text - if I ente