Multiple file string replacement
I am looking for some application to replace a mulitple line string with another mulitple line sring in all .txt files in a folder.
I would rather have an application. I am familiar with the terminal and would use if this was the only way.
Does TextWranger do this?
Robert
Thanks for pointing out TextWrangler
The multi-file find works on multiple lines with Unix line ends. The multi-file find doesn't work when the lines contain tabs ( \t ). I first tried a replace with 25 lines that contained tabs and line ends which didn't work.
I thinking of modifying some Bash scripts that I have. I have a perl script the deals with line ends.
Robert
Similar Messages
-
Find and replace with multiple files and with a watch folder
I am trying to create a watch folder that uses red_menace script to:
1. Have a folder that receives multiple xml files that run the script one by one.
2. then move the files to an output folder.
I tried modifying the set TheFIle to choose file -- the original text file to:
with multiple selections allowed
But that doesn't seem to work. I know i'm missing a step. Any help is much appreciated!
Thanks!
The way i'd like to setup things is having an input folder on the desktop (or just have the application on the desktop and I can drag the files onto it), and let it do it's thing. Once it's done have it export the xml files into an output folder.
Here's what i got so far:
on open
set TheFIle to choose file -- the original text file
set TheFolder to ("Macintosh HD:Users:user1:Desktop:out") -- the folder for the output file
set TheName to (GetUniqueName for TheFIle from TheFolder) -- the name for the output file
set TheText to read TheFIle -- get the text to edit
set Originals to {"KPCALDATE", "KPCALEVENT", "KPCALDAY", "KPCALBODY", "obituaries name", "" & return & "</cstyle></pstyle>" & return & "<pstyle name=\"obituaries text\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>", " .com", " .net", " .org", " .edu", "www .", "www. ", "Ho- nolulu", "<pstyle name=\"kicker 12\"><cstyle allcaps=\"1\">fashion news</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "<component name=\"Headline 1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline 1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 36\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>-", "-", "
Per serving:", "<pstyle name=\"Titlebar - mini, red\"><cstyle allcaps=\"1\">NATION & World </cstyle><cstyle allcaps=\"1\">Report</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "</cstyle></pstyle>"} -- the terms that can be replaced
set Replacements to {"subhed", "subhed", "subhed", "Normal", "obituaries text", ", ", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>
", ".com", ".net", ".org", ".edu", "www.", "www.", "Honolulu", "", "<component name=\"Headline1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 27\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>", " ", "
Per serving:", "","" & return & "</cstyle></pstyle>"} -- the replacement terms
repeat with AnItem from 1 to count Originals
set TheText to (replaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
end repeat
try -- write a new output file
tell application "Finder" to make new file at TheFolder with properties {name:TheName}
set OpenFile to open for access (result as alias) with write permission
write TheText to OpenFile starting at eof
close access OpenFile
on error errmess
try
log errmess
close access OpenFile
end try
end try
end open
to GetUniqueName for SomeFile from SomeFolder
check if SomeFile exists in SomeFolder, creating a new unique name if needed
parameters - SomeFile [mixed]: a source file path
SomeFolder [mixed]: a folder to check
returns [text]: a unique file name and extension
set {Counter, Divider} to {"00", "_"}
-- get the name and extension
set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
if TheExtension is missing value then set TheExtension to ""
set TheName to text 1 thru -((count TheExtension) + 2) of TheName
set NewName to TheName & "." & TheExtension
tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
repeat while it contains NewName
set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
set NewName to TheName & Divider & Counter & "." & TheExtension
end repeat
end tell
return NewName
end GetUniqueName
to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
displays a dialog for multiple item edit (note that a return is used between each edit item)
for each of the items in SomeItems, a line containing it's text is placed in the edit box
the number of items returned are padded or truncated to match the number of items in SomeItems
parameters - SomeItems [list]: a list of text items to edit
TheTitle [boolean/text]: use a default or the given dialog title
ThePrompt [boolean/text]: use a default or the given prompt text
returns [list]: a list of the edited items, or {} if error
set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
if TheCount is less than 1 then return {} -- error
if ThePrompt is in {true, false} then -- "with" or "without" Prompt
if ThePrompt then
set ThePrompt to "Edit the following items:" & return -- default
else
set ThePrompt to ""
end if
else -- fix up the given prompt a little
set ThePrompt to ThePrompt & return
end if
if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
set TheTitle to "Multiple Edit Dialog" -- default
else
set TheTitle to ""
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
repeat with AnItem from 1 to TheCount -- pad/truncate entered items
try
set the end of TheItems to (item AnItem of TheInput)
on error
set the end of TheItems to ""
end try
end repeat
return TheItems
end EditItems
to replaceText of SomeText from OldItem to NewItem
replace all occurances of OldItem with NewItem
parameters - SomeText [text]: the text containing the item(s) to change
OldItem [text]: the item to be replaced
NewItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
set SomeText to SomeText as Unicode text -- TID's are case insensitive with Unicode text
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
return SomeText
end replaceText
Message was edited by: gamebreakersWhen you use the open or adding folder items to handlers, you need to add the parameters for the file items passed to them.
I'll go ahead and post the applet/droplet version of my original script from the previous topic for reference:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- search and replace multiple items applet/droplet/folder action
-- the terms to replace - edit as needed
property EditableItems : {¬
"one", ¬
"two", ¬
"three", ¬
"four", ¬
"five", ¬
"six", ¬
"seven", ¬
"eight", ¬
"nine", ¬
"ten", ¬
"eleven", ¬
"twelve", ¬
"thirteen", ¬
"fourteen", ¬
"fifteen", ¬
"sixteen", ¬
"seventeen", ¬
"eighteen", ¬
"nineteen", ¬
"twenty"}
-- the folder for the output file(s) - change as needed
property TheFolder : (path to desktop)
property LastEditItems : EditableItems
on run
the applet/droplet was double-clicked
open (choose file with multiple selections allowed)
end run
on open TheItems
items were dropped onto the applet/droplet
parameters - TheItems [list]: a list of the items (aliases) dropped
returns nothing
repeat with AnItem in TheItems
ReplaceMultipleItems from AnItem
end repeat
end open
on adding folder items to this_folder after receiving these_items
folder action - items were added to a folder
parameters - this_folder [alias]: the folder added to
these_items [list]: a list if items (aliases) added
returns nothing
repeat with AnItem in these_items
ReplaceMultipleItems from AnItem
end repeat
end adding folder items to
to ReplaceMultipleItems from SomeFile
replace multiple text items in SomeFile
parameters - SomeFile [alias]: the file to replace items in
returns nothing
set TheName to (GetUniqueName for SomeFile from TheFolder) -- the name for the output file
set TheText to read SomeFile -- get the text to edit
set Originals to (choose from list EditableItems default items LastEditItems with prompt "Select the terms to replace:" with multiple selections allowed) -- the specific terms to replace
set LastEditItems to Originals
set Replacements to (EditItems of Originals with Title given Prompt:"Edit the following replacement terms:") -- the replacement terms
repeat with AnItem from 1 to count Originals
set TheText to (ReplaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
end repeat
try -- write a new output file
tell application "Finder" to make new file at TheFolder with properties {name:TheName}
set OpenFile to open for access (result as alias) with write permission
write TheText to OpenFile starting at eof
close access OpenFile
on error errmess
try
log errmess
close access OpenFile
end try
end try
end ReplaceMultipleItems
to GetUniqueName for SomeFile from SomeFolder
check if SomeFile exists in SomeFolder, creating a new unique name if needed
parameters - SomeFile [mixed]: a source file path
SomeFolder [mixed]: a folder to check
returns [text]: a unique file name and extension
set {Counter, Divider} to {"00", "_"}
-- get the name and extension
set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
if TheExtension is in {missing value, ""} then
set TheExtension to ""
else
set TheExtension to "." & TheExtension
end if
set {NewName, TheExtension} to {TheName, (ChangeCase of TheExtension to "upper")}
set TheName to text 1 thru -((count TheExtension) + 1) of TheName
tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
repeat while it contains NewName
set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
set NewName to TheName & Divider & Counter & TheExtension
end repeat
end tell
return NewName
end GetUniqueName
to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
displays a dialog for multiple item edit (note that a return is used between each edit item)
for each of the items in SomeItems, a line containing it's text is placed in the edit box
the number of items returned are padded or truncated to match the number of items in SomeItems
parameters - SomeItems [list]: a list of text items to edit
TheTitle [boolean/text]: use a default or the given dialog title
ThePrompt [boolean/text]: use a default or the given prompt text
returns [list]: a list of the edited items, or {} if error
set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
if TheCount is less than 1 then return {} -- error
if ThePrompt is in {true, false} then -- "with" or "without" Prompt
if ThePrompt then
set ThePrompt to "Edit the following items:" & return -- default
else
set ThePrompt to ""
end if
else -- fix up the given prompt a little
set ThePrompt to ThePrompt & return
end if
if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
set TheTitle to "Multiple Edit Dialog" -- default
else
set TheTitle to ""
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
repeat with AnItem from 1 to TheCount -- pad/truncate entered items
try
set the end of TheItems to (item AnItem of TheInput)
on error
set the end of TheItems to ""
end try
end repeat
return TheItems
end EditItems
to ReplaceText of SomeText from OldItem to NewItem
replace all occurances of OldItem with NewItem
parameters - SomeText [text]: the text containing the item(s) to change
OldItem [text]: the item to be replaced
NewItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
set SomeText to SomeText as text
if SomeText contains OldItem then
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
try
set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
on error ErrorMessage number ErrorNumber -- oops
set AppleScript's text item delimiters to TempTID
error ErrorMessage number ErrorNumber
end try
end if
return SomeText
end ReplaceText
to ChangeCase of SomeText to CaseType
changes the case or capitalization of SomeText to the specified CaseType using Python
parameters - SomeText [text]: the text to change
CaseType [text]: the type of case desired:
"upper" = all uppercase text
"lower" = all lowercase text
"title" = uppercase character at start of each word, otherwise lowercase
"capitalize" = capitalize the first character of the text, otherwise lowercase
returns [text]: the changed text
set SomeText to SomeText as text
if CaseType is not in {"upper", "lower", "title", "capitalize"} then return SomeText
return (do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8')." & CaseType & "().encode('utf8')\" " & quoted form of SomeText)
end ChangeCase
</pre>
Edit: how does the choose from list dialog handle those big strings? I'm guessing not very well - is that why you avoided using them?
Message was edited by: red_menace -
Multiple file search and replace
Does anyone know if it is possible to do search / replaces in script, text etc over multiple files? If not, is there any 3rd party software available to do it?
I have hundreds of files I have to make the same change in and just wanted to find out before I have to do the mind-numbing process of going through them all.
Any help will be greatly appreciated!Depending upon what type of files and what kind of changes you need to make, sure you can. You can do a google search for 'binary search and replace'; here's one of the first results, which searches for and replaces strings in multiple text and/or binary files:
http://gnuwin32.sourceforge.net/packages/gsar.htm -
Split text file in multiple files based on a string
Hey all,
I want to split a text file into multiple files. I already found some examples where there is a split based on a number of files.
http://forum.java.sun.com/thread.jspa?forumID=256&threadID=260930
But I want to make a split based on a string (word) that I find in the file.
Anyone that can help me ?
Regards,
AtmozThis is my testing code like it is now. Maybe there is a bug in there which causes a memory leak or so.
public class test {
public static void main(String args[]) {
File sSourceDir = new File("D:\\Test\\");
File sDestinationDir = new File("D:\\Test\\");
File[] files = sSourceDir.listFiles(new Filter());
for (int i=0; i<files.length; i++) {
File file = files;
if (file.isFile()) {
System.out.println("Splitting file: "+files[i]);
splitFile(file,sDestinationDir);
else {
System.out.println("Not a file: "+files[i]);
public static File splitFile(File fSourceFile, File sDestinationDir) {
int counter = 1;
File fDestinationFile=new File(sDestinationDir,"NEW_"+counter+"_"+fSourceFile.getName());
fDestinationFile.delete();
String sLineOfData=null;
boolean firstfile = true;
try {
BufferedReader DataFileReader = new BufferedReader(new FileReader(fSourceFile));
PrintWriter outputStream = new PrintWriter(new FileWriter(fDestinationFile));
while ((sLineOfData = DataFileReader.readLine()) != null){
System.out.println(sLineOfData);
if (sLineOfData.indexOf("UNA:+") != -1) {
if (!firstfile) {
counter++;
fDestinationFile=new File(sDestinationDir,"NEW_"+counter+"_"+fSourceFile.getName());
outputStream.close();
outputStream = new PrintWriter(new FileWriter(fDestinationFile));
outputStream.println(sLineOfData);
else {
firstfile = false;
outputStream.println(sLineOfData);
else {
outputStream.println(sLineOfData);
outputStream.close();
DataFileReader.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return fSourceFile;
And this is an example of a file:
PS: I cut out each long line (that line from 4000 chars)
UNA:+,? '
UNB+UNOC:3d+5499757493404:14+3014331700208:14+050114:1200+ACC302++STS.GZ++1++1'
UNH+I15185477+UTILTS:D:03B:UN:E5BE03'BGM+E32::260+I15185477+9+NA'
DTM+137:200501141151:203'DTM+735:?+0100:406'MKS+23'NAD+MR+3014331700208::9'
UNA:+,? '
UNB+UNOC:3+549975f7493404:14+3014331700208:14+050114:1200+ACC302++STS.GZ++1++1'
UNH+I15185477+UTILTS:D:03B:UN:E5BE03'BGM+E32::260+I15185477+9+NA'
DTM+137:200501141151:203'DTM+735:?+0100:406'MKS+23'NAD+MR+3014331700208::9'
DTM+137:200501141151:203'DTM+735:?+0100:406'MKS+23'NAD+MR+3014331700208::8'
UNA:+,? '
UNB+UNOC:3g+5499757g493404:14+3014331700208:14+050114:1200+ACC302++STS.GZ++1++1'
UNH+I15185477+UTILTS:D:03B:UN:E5BE03'BGM+E32::260+I15185477+9+NA'
DTM+137:200501141151:203'DTM+735:?+0100:406'MKS+23'NAD+MR+3014331700208::9'Message was edited by:
Atmozzz -
Hey folks, is there a way to batch replace multiple files within AE CC? Or would this require a script?
I have around 100 or 150 precomps that I need to replace with png image sequences.
Thanks for your tips!
MLDon't know but i'd really love this new feature in futur update
-
Email notification to specific user when processing multiple files at a time
Hi
I am new to SSIS and error mail notification ,can some please provide details for my urgent and prioritized task in my project.
below is the requirement
I have a package for multiple file processing using for each file enumerator .each file having same column definition but for different
users and different name .
i have some mandatory fields to form unique id on combination
1.when files processing any data missed on mandatory fields it should alert users saying following line and fields are missing mandatory
information
2.email notification should send to respective users based on file name.
example :
file1:bitunimous.xls
file 2.oxford.xls
each file having following fields
file 1:bitunimous.xls
claim no: claimant: subclaim:
1001 abc 0
1002 abc 1
1002 abe 0
1004 0
here bitunimous.xls missed claimant value for 4th line then email needs to send to [email protected] as
line no 4 missed claimant information for unique key generation like that.
file 2.oxford.xls
claim no: claimant: subclaim:
2001 det 0
2002 pre 1
pqr 0
2004 frc
here oxford.xls missed claimno value for 3rd line then email needs to send to [email protected] as
line no 3 missed claimno information for unique key generation like that.
can anybody please provide solution
Thanks .
AmbedYou need to have a package with below work flow
1. ForEachLoop container with file enumerator to loop through files
Have variable inside loop to get the filename during each iteration. Create another variable called emailaddress, set EvaluateAsExpression property to true and set expression as
REPLACE(@[User::FileName],".xls","") + (DT_STR,20,1252) "@xyx.com"
2. Add tasks for validating data. Capture details of error on a string variable @[User::Error]
3. link a sent mail task to previous task and choose expression and constraint option. Set Constraint as On Completion and Expression as LEN(@Error) > 0
Inside Sent mail task set expression for ToLine and MessageSource properties to map to variables @[User::EmailAddress] and @{User::Error] respectively to sent notifications
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to prompt user to select multiple files in file dialog using scripts
Hi, is there a way to allow user to select multiple files inside the file dialog using scripts? So not just something like "*.ai" or "*.eps" but where the user can actually use their shift key to select a batch of files inside the file dialog and then the script would process each one.
Thanks!// Main Code [Execution of script begins here]
here's what I have so far. it would also be nice to not have illustrator stop at errors.. right now, it skips dialogs but on errors, it still stops.
// uncomment to suppress Illustrator warning dialogs
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts, folderName;
var fullPath = "";
var finalSlash;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator .ai files you want to convert to PDF');
f = find_files(sourceFolder);
function find_files (dir)
return find_files_sub (dir, []);
function find_files_sub (dir, array)
var f = Folder (dir).getFiles ("*.*");
for (var i = 0; i < f.length; i++)
if (f[i] instanceof Folder)
find_files_sub (f[i], array);
else
if (f[i].name.slice (-3).toLowerCase() == ".ai" || f[i].name.slice (-4).toLowerCase() == ".eps")
//convert the array-listing to a string so we can manipulate it
fullPath = String(f[i]);
//find the position of the last / to indicate where the filename starts
finalSlash = fullPath.lastIndexOf("/");
//get the foldername by "slicing" from start to where finalSlash is located
folderName = fullPath.slice(0, finalSlash).toLowerCase();
sourceDoc = app.open(f[i]); // returns the document object
// Call function getNewName to get the name and file to save the pdf
targetFile_PNG = getNewName(".png");
if(targetFile_PNG.exists) {
} else {
pngExportOpts = getPNGOptions();
sourceDoc.exportFile(targetFile_PNG, ExportType.PNG24, pngExportOpts );
targetFile_PDF = getNewName(".pdf");
pdfSaveOpts = getPDFOptions();
sourceDoc.saveAs(targetFile_PDF, pdfSaveOpts );
targetFile_SVG = getNewName(".svg");
svgSaveOpts = getSVGOptions();
sourceDoc.exportFile(targetFile_SVG, ExportType.SVG, svgSaveOpts );
sourceDoc.close();
array.push (f[i]);
getNewName: Function to get the new file name. The primary
name is the same as the source file.
function getNewName(ext)
var ext, docName, newName, saveInFile, docName, finalDot
var loop = 0;
docName = sourceDoc.name;
ext = ext; // new extension for pdf file
newName = "";
finalDot = sourceDoc.name.lastIndexOf(".");
while(loop < finalDot)
newName += docName[loop];
loop = loop + 1;
newName += ext; // full pdf name of the file
newName = newName.replace(" [Converted]","");
// Create a file object to save the pdf
saveInFile = new File( folderName + '/' + newName );
return saveInFile;
getPDFOptions: Function to set the PDF saving options of the
files using the PDFSaveOptions object.
function getPDFOptions()
// Create the PDFSaveOptions object to set the PDF options
var pdfSaveOpts = new PDFSaveOptions();
// Setting PDFSaveOptions properties. Please see the JavaScript Reference
// for a description of these properties.
// Add more properties here if you like
pdfSaveOpts.acrobatLayers = false;
pdfSaveOpts.colorBars = false;
pdfSaveOpts.colorCompression = CompressionQuality.AUTOMATICJPEGHIGH;
pdfSaveOpts.compressArt = true; //default
pdfSaveOpts.embedICCProfile = false;
pdfSaveOpts.enablePlainText = false;
pdfSaveOpts.generateThumbnails = false; // default
pdfSaveOpts.optimization = true;
pdfSaveOpts.pageInformation = false;
pdfSaveOpts.preserveEditability = true;
return pdfSaveOpts;
function getSVGOptions()
var svgSaveOpts = new ExportOptionsSVG();
//just using defaults aside from what's written below
//see http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csawlib/com/adobe/illustrator/ ExportOptionsSVG.html
svgSaveOpts.embedRasterImages = true;
svgSaveOpts.sVGTextOnPath = true;
return svgSaveOpts;
function getPNGOptions()
// Create the PDFSaveOptions object to set the PDF options
var pngExportOpts = new ExportOptionsPNG24();
// Setting PNGExportOptions properties. Please see the JavaScript Reference
// for a description of these properties.
// Add more properties here if you like
pngExportOpts.antiAliasing = true;
pngExportOpts.artBoardClipping = false;
pngExportOpts.horizontalScale = 100; // scaling to 350%
pngExportOpts.saveAsHTML = false;
pngExportOpts.transparency = true;
pngExportOpts.verticalScale = 100; // scaling to 350%
return pngExportOpts; -
Problems selecting multiple files
I just replaced my MacBook Pro with a newer version. I am trying to organize my photos and cannot select multiple files or photos.
I'm needing to organize in Pictures not iPhoto.
I've had Macs for years and never had an issue before.
Thanks,the problem is you are not stoping the writing to file when you hit the end of one file.
At the server you should count the number of bytes that you write to the disk and should stop when the total count reach the file size.
Or you have to completly change your protocole to handle entire file as one unit.
Ex:-
public class MyFile implements java.io.Serializable{
String path;
private void writeObject(ObjectOutputStream oos){
oos.defaultWriteObject();
byte b[] = new byte[1024*128];
int i = 0;
FileInputStream fis = new FileInputStream(path);
while ((i = fis.read(b)) >=0){
oos.writeObject(trim(b,i));
fis.close();
oos.writeObject("EOF");
private byte[] trim(byte b[], int i){
byte b2[] = new byte;
System.arraycopy(b,0,b2,0,i);
return b2;
// You should be able to write the read object method -
Multi File Find/Replace: XP
Good afternoon,
When trying to do a find and replace (or just a find) across
multiple files, HS is no longer working. It will not find any
instances of the search string in any document. If the search is
done on a single document, then it does indeed work.
Using HomeSite 5.5 (version 6.0.0.7658) on Windows XP
Professional.
This is happening on multiple computers at our location.
Thanks
FredI was able to get it working again by uninstalling HomeSite
and then reinstalling it.
There's probably a better way but when all else fails
reinstall and reboot. -
Upload multiple files WITH correct pairs of form fields into Database
In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
if(item.isFormField()){
}else{
}I seems to be restricted from this structure.
The jsp form page
<input type="text" name="description1" value="" />
<input type="file" name="sourcefile" value="" />
<input type="text" name="description2" value="" />
<input type="file" name="sourcefile" value="" />The Servlet file
package Upload;
import sql.*;
import user.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
public class UploadFile extends HttpServlet {
private String fs;
private String category = null;
private String realpath = null;
public String imagepath = null;
public PrintWriter out;
private Map<String, String> formfield = new HashMap<String, String>();
//Initialize global variables
public void init(ServletConfig config, ServletContext context) throws ServletException {
super.init(config);
//Process the HTTP Post request
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Thumbnail thumb = new Thumbnail();
fs = System.getProperty("file.separator");
this.SetImagePath();
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if(!isMultipart){
out.print("not multiple part.");
}else{
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try{
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if(item.isFormField()){
String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
formfield.put(item.getFieldName(),formvalue);
out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
}else{
String itemName = item.getName();
String filename = GetTodayDate() + "-" + itemName;
try{
new File(this.imagepath + formfield.get("category")).mkdirs();
new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
//Save the file to the destination path
File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
item.write(savedFile);
thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
DBConnection db = new DBConnection();
String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
db.SelectQuery(sql);
while(db.rs.next()){
int cat_id = db.rs.getInt("id");
sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
out.println(sql);
db.RunQuery(sql);
} catch (Exception e){
e.printStackTrace();
HttpSession session = request.getSession();
UserData k = (UserData)session.getAttribute("userdata");
k.setMessage("File Upload successfully");
response.sendRedirect("./Upload.jsp");
//Get today date, it is a test, actually the current date can be retrieved from SQL
public String GetTodayDate(){
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String today = format.format(new Date());
return today;
//Set the current RealPath which the file calls for this file
public void SetRealPath(){
this.realpath = getServletConfig().getServletContext().getRealPath("/");
public void SetImagePath(){
this.SetRealPath();
this.imagepath = this.realpath + "images" +fs;
}Can anyone give me some code suggestion? Thx.When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
In any case you may look at how you are Uploading Multiple Files with mod_plsql. -
How to store multiple files from SAp in to Application server?
Hi Guys,
Can anybody tell me how to store multiple files from SAP into Application server.in my application i have to get the data from SAP tables BSEG , BKPF , BSAK and BSIK that to daily i have to do.
Any Logic or Code for how to do is welcomed.
plz help me urgently.
Thanks,
GopiHi,
directories creates basis. If you have task to store data in application server you already should have information into which folder you have to do it. If you don't have this information because it is just for example training for next task then you can use your personal folder into which you have access. To get list of all available folders please look at attached code and form get_directories (you get the list of folders you see in transaction AL11). But don't forget: If you are using open dataset you have to have rights to access application folder!
Here you are code which I use to upload text files from local disc into application folder
Regards,
Karol
*& Report FILE_PC_TO_SAP
REPORT FILE_PC_TO_SAP.
DATA: BEGIN OF searchpoints OCCURS 100,
DIRNAME(200) TYPE c, " name of directory.
sp_name(100) TYPE c," name of entry. (may end with *)
END OF searchpoints.
DATA: BEGIN OF isearchpoints OCCURS 10,
dirname(75) TYPE c, " name of directory.
aliass(75) TYPE c, " alias for directory.
svrname(75) TYPE c, " svr where directory is availabl
sp_name(75) TYPE c, " name of entry. (may end with *)
sp_cs(10) TYPE c, " ContainsString pattern for name
END OF isearchpoints.
data: l_file type filetable.
data: l_rc type i.
data: itab type TABLE OF string.
data: g_tmp_file_path type rlgrap-filename.
data: wa_itab type string.
data: h_destin(100) type c.
data: dat type string.
INITIALIZATION.
perform get_directories.
START-OF-SELECTION.
parameters: in_file type string OBLIGATORY LOWER CASE.
parameters: destin(100) type c OBLIGATORY LOWER CASE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = in_file
"FILETYPE = 'BIN'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF sy-SUBRC <> 0.
write: / 'Error during loading input file!'.
ENDIF.
if h_destin is INITIAL.
h_destin = in_file.
endif.
CONCATENATE destin h_destin into dat SEPARATED BY '/'.
*TRANSLATE dat TO UPPER CASE.
OPEN DATASET dat FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-SUBRC = 0.
loop at itab into wa_itab.
TRANSFER: wa_itab TO dat.
endloop.
CLOSE DATASET dat.
write: / 'File uploaded!'.
ELSE.
write: / 'Not possible to open dataset'.
ENDIF.
at selection-screen on value-request for in_file.
perform select_input_file_name.
loop at l_file into g_tmp_file_path.
move g_tmp_file_path to in_file.
h_destin = ''.
SPLIT g_tmp_file_path at '\' into table itab.
loop at itab into g_tmp_file_path.
h_destin = g_tmp_file_path.
endloop.
endloop.
at selection-screen on value-request for destin.
DATA: lt_dfies TYPE TABLE OF dfies.
DATA: lwa_dfies TYPE dfies.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = '/BI0/PCO_AREA'
lfieldname = 'CO_AREA'
IMPORTING
dfies_wa = lwa_dfies.
lwa_dfies-tabname = 'searchpoints'.
lwa_dfies-REPTEXT = 'Destination directory'.
lwa_dfies-LENG = 100.
lwa_dfies-INTLEN = 100.
lwa_dfies-OUTPUTLEN = 100.
lwa_dfies-fieldname = 'SP_NAME'.
APPEND lwa_dfies TO lt_dfies.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'SP_NAME'
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'destin'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = searchpoints
FIELD_TAB = lt_dfies
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
*& Form select_input_file_name
* text
form select_input_file_name.
* call function 'F4_FILENAME'
* exporting
* program_name = sy-repid
* dynpro_number = sy-dynnr
* field_name = 'PATH'
* importing
* file_name = g_tmp_file_path.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Please choose a file'
"default_extension = '*.TXT'
"default_filename = 'C:\*.txt'
initial_directory = 'C:\'
file_filter = '*.*'
CHANGING
FILE_TABLE = l_file
RC = l_RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. "select_input_file_name
*& Form WRITE_DB_HOME
* Write DB home directory
* no parameters
FORM write_db_home.
CASE sy-dbsys(3).
WHEN 'ORA'.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ORAHOME'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_ORAHOME', 30 searchpoints-dirname.
MOVE: 'DIR_ORAHOME' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
WHEN 'ADA'.
CALL 'C_GETENV' ID 'NAME' FIELD 'DBROOT'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_ADA_DBROOT', 30 searchpoints-dirname.
MOVE: 'DIR_ADA_DBROOT' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
WHEN 'INF'.
CALL 'C_GETENV' ID 'NAME' FIELD 'INFORMIXDIR'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_INF_INFORMIXDIR', 30 searchpoints-dirname.
MOVE: 'DIR_INF_INFORMIXDIR' TO searchpoints-sp_name.
APPEND searchpoints..
*--- C5056155 End of ALV -------------------------------*
WHEN 'DB6'.
CALL 'C_GETENV' ID 'NAME' FIELD 'INSTHOME'
ID 'VALUE' FIELD searchpoints-dirname.
IF sy-subrc = 0.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_DB2_HOME', 30 searchpoints-dirname.
MOVE: 'DIR_DB2_HOME' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
ELSE.
EXIT.
ENDIF.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDFORM. " WRITE_DB_HOME
FORM get_directories.
* get the name and aliases of ALL userdefined directories
SELECT * FROM user_dir INTO isearchpoints
WHERE svrname = sy-uname.
MOVE isearchpoints-dirname to searchpoints-dirname.
MOVE isearchpoints-aliass to searchpoints-sp_name.
APPEND searchpoints.
ENDSELECT.
SELECT * FROM user_dir INTO isearchpoints
WHERE svrname = 'all'.
MOVE isearchpoints-dirname to searchpoints-dirname.
MOVE isearchpoints-aliass to searchpoints-sp_name.
APPEND searchpoints.
ENDSELECT.
* Get DB home
IF sy-dbsys(3) = 'ADA'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ATRA'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_ATRA' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_BINARY'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_BINARY' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory $DIR_CCMS
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CCMS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CCMS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CT_LOGGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CT_LOGGING' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CT_RUN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CT_RUN' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_DATA'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_DATA' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'DB6'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_DBMS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_DBMS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_EXECUTABLE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_EXECUTABLE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_EXE_ROOT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_EXE_ROOT' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GEN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GEN' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GEN_ROOT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GEN_ROOT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GLOBAL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GLOBAL' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GRAPH_EXE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GRAPH_EXE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GRAPH_LIB'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GRAPH_LIB' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_HOME'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_HOME' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'INF'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_INSTALL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_INSTALL' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_INSTANCE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_INSTANCE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_LIBRARY'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_LIBRARY' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_LOGGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_LOGGING' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the files written by the memory inspector
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_MEMORY_INSPECTOR'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_MEMORY_INSPECTOR' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'ORA'.
PERFORM write_db_home.
ENDIF.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PAGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PAGING' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PUT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PUT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PERF'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PERF' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PROFILE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PROFILE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PROTOKOLLS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PROTOKOLLS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_REORG'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_REORG' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ROLL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_ROLL' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_RSYN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_RSYN' TO searchpoints-sp_name.
APPEND searchpoints.
* calculate directory for saphostagent (no sapparam available...)
IF ( sy-opsys(3) = 'WIN' ) OR ( sy-opsys(3) = 'Win' ).
DATA: windir_path(64), programfiles_path(64).
* hoping that ProgramFiles is set in service user environment
CALL 'C_GETENV' ID 'NAME' FIELD 'ProgramFiles'
ID 'VALUE' FIELD programfiles_path.
IF programfiles_path IS INITIAL.
* %ProgramFiles% not available. guess from windir
CALL 'C_GETENV' ID 'NAME' FIELD 'windir'
ID 'VALUE' FIELD windir_path.
* e.g. S:\WINDOWS ==> S:\Program Files
CONCATENATE windir_path(3) 'Program Files' INTO programfiles_path.
ENDIF.
CONCATENATE programfiles_path '\SAP\hostctrl'
INTO searchpoints-dirname.
ELSE.
* on UNIX, the path is hard coded
searchpoints-dirname = '/usr/sap/hostctrl'.
ENDIF.
MOVE: 'DIR_SAPHOSTAGENT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SAPUSERS'
ID 'VALUE' FIELD searchpoints-dirname.
IF searchpoints-dirname = '.'.
IF sy-opsys = 'Windows NT'.
searchpoints-dirname = '.\'.
ELSE.
searchpoints-dirname = './'.
ENDIF.
ENDIF.
MOVE: 'DIR_SAPUSERS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SETUPS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SETUPS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SORTTMP'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SORTTMP' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SOURCE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SOURCE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TEMP'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TEMP' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRANS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRANS' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRFILES'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRFILES' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRSUB'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRSUB' TO searchpoints-sp_name.
APPEND searchpoints.
* get the name of the current server.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'rdisp/myname'
ID 'VALUE' FIELD searchpoints-dirname.
data: h_ind type i.
LOOP AT searchpoints.
h_ind = sy-tabix.
IF searchpoints-sp_name IS INITIAL.
DELETE searchpoints INDEX h_ind.
ENDIF.
ENDLOOP.
ENDFORM. -
Hello
I am trying to run multiple files with my java app on a Unix server. I compiled with javac, and run it thus:
java SNL *.mef
meaning I want to run all of the files with .mef suffix. Unfortunately it does nothing. If I just run one file at time this way:
java SNL bach.mef
it will work just fine. My main method looks like this:
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.exit(-1);
} else {
File file = new File(args[0]);
SNL parseSNL = new SNL(file);
Any help would be greatly appreciated.
JMpublic static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println( "Usage: java SNL x.mef y.mef ..." );
System.exit(-1);
} else {
for( int i=0; i<args.length; i++ ) {
File file = new File( args[i] );
System.out.println( "Parsing " + file.getAbsolutePath() + " ..." );
SNL parseSNL = new SNL(file); -
Sending multiple files using one socket
Hi guys
I'm working on a simple app that sends multiple files over LAN or I-NET. The problem is that the app run seems to be non-deterministic. I keep getting this error on the client side:
java.io.UTFDataFormatException: malformed input around byte 5
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at service.DownloadManager.storeRawStream(DownloadManager.java:116)
at service.DownloadManager.downloadFiles(DownloadManager.java:47)
at manager.NetworkTransferClient$1.run(NetworkTransferClient.java:104)The byte position changes every time I run a transfer. The error is caused by this line: String fileName = in.readUTF(); Here's the complete code:
Client
private void storeRawStream() {
try {
FileOutputStream fileOut;
int fileCount = in.readInt();
for(int i=0; i<fileCount; i++) {
byte data[] = new byte[BUFFER];
String fileName = in.readUTF();
fileOut = new FileOutputStream(new File(upload, fileName));
long fileLength = in.readLong();
for(int j=0; j<fileLength / BUFFER; j++) {
int totalCount = 0;
while(totalCount < BUFFER) {
int count = in.read(data, totalCount, BUFFER - totalCount);
totalCount += count;
fileOut.write(data, 0, totalCount);
fileOut.flush();
bytesRecieved += totalCount;
// read the remaining bytes
int count = in.read(data, 0, (int) (fileLength % BUFFER));
fileOut.write(data, 0, count);
fileOut.flush();
fileOut.close();
transferLog.append("File " + fileName + " recieved successfully.\n");
} catch (Exception ex) {
ex.printStackTrace();
}Server
public void sendFiles(File[] files) throws Exception {
byte data[] = new byte[BUFFER];
FileInputStream fileInput;
out.writeInt(files.length);
for (int i=0; i<files.length; i++) {
// send the file name
out.writeUTF(files.getName());
// send the file length
out.writeLong(files[i].length());
fileInput = new FileInputStream(files[i]);
int count;
while((count = fileInput.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
bytesSent += count;
fileInput.close();
out.flush();
Does anybody know where's the problem? Thanx for any reply.Send the length of each file ahead of each file, with DataOutputStream.writeLong().
When reading, read that long, then stop reading bytes when you've read exactly that length. -
How to send multiple files in parallel using ftp with single connection
Hi.
i have written code for file upload manager using ftp..
it perfectly working with sequence file uploading in single connection..
And i tried to upload multiple files with parallel processing in a single connection.... but it is not working properly.. i also used thread concept
but single file only transfered and connection refused...
my code here...
//////////////////// main class //////////////////////////////////////////
ftp.connect();
ftp.login();
String [] archivos = new String[100];
File dir = new File("C:\\Files Uploading\\");
archivos = dir.list();
for (int s=0; s<archivos.length;s++)
//Start Data Transfer Here
new DataTransfer(archivos[s]).start();
Thread.sleep(1000);
/////////////////////// thread class ////////////////////////////////
class DataTransfer extends Thread
String FileName="";
String LocalPath="",RemotePath="";
public DataTransfer(String fname)
FileName = fname;
LocalPath = "C:\\Files Uploading\\" + FileName;
RemotePath = FileName;
System.out.println(LocalPath);
public void run()
System.out.println("DataTransfer Started");
/File Transfer Here
try
FileInputStream input = new FileInputStream(LocalPath);
Ftp_Client.storeFile(RemotePath,input);
System.out.println("Successfully sent : " + RemotePath);
catch (Exception exc)
System.out.println(exc.getMessage());
System.out.println("DataTransfer Ended");
}otherwise tell me any other alternate wayAnd i tried to upload multiple files with
parallel processing in a single connection....
but it is not working properly.FTP isn't a multiplexing protocol. How could it work at all? -
How ATTACH multiple files from different folders in one ATTACH 'session'?
Hi,
In Mac Mail, I often have to attach 2 or 3 separate files, all from different folder locations on my hard drive.
This requires clicking attach, selecting file 1 and clicking OK, which closes the Attach dialog.
Then I have to do it again 2 times for each other file. oy.
Is there a way to Highlight multiple files in different directories (ala Command-Select...which doesn't work) before selecting OK?
OR
I've found that I can DRAG a file from the Attach dialog into the email and the dialog will remain open, only the file is HIGHLIGHTED in the email and , hence, gets replaced by the next file I drag into the email (or select by the normal method)....
Is there a way to drag that file#1 into the email and have it NOT remain highlighted, so that I can pick another file to add in addition to that one?
Thanks!ShizzleFizzle wrote:
Is there a way to Highlight multiple files in different directories (ala Command-Select...which doesn't work) before selecting OK?
Have you tried dragging files from Finder windows into the mail message window?
Maybe you are looking for
-
Jabber for Windows 9.2.2 - Unable to make calls from PC
I have implement CUCM 9.1(1a) and CUP 9.1(1a) I can make calls if i used desk phone for calls but iam unable to make calls whet i turn the option use pc to make calls p.s: i have set up CCMCIP (CUCM ip address) for all users.
-
my ipod touch got stolen and when i got it back it said ipod disabled connect to iTunes how do i get my information from notes, contacts, etc. and apps on it back while restarting it through iTunes?
-
Unable to view jpeg photos using Quicktime
Trying to open any jpeg photos crashes Quicktime 7.4.5. I've tried uninstall/reinstall of Quicktime and still no luck. I had to switch to windows picture viewer. Man, they're have been a lot of issues with Quicktime lately...I see the Buffer overrun
-
What type of tables are stored in TVDIR ???
Hi Experts, I have created one custom table " ZEMPLOYEE ". I activated it succesfully without any type errors.But it is not found in this table TVDIR. What might be the reason ? <b>What type of tables are stored in TVDIR ???</b> Regard
-
Flattening a PDF - please help - urgent
I have Adobe Acrobat Professional 7.0 and I'm trying to send a client a pdf proof on a 2 spot color job. When the client receives it she does not see the 2nd spot color - (I can go to advance and check output preview and it shows up fine on my machin