How to copy a file with subdirectory tree
The output for the code will copy a .doc file from c:/copy to c:/test. How am I able to copy a tree directory. For example from c:/copy/1.doc, c:/copy/tutor/2.doc to c:/test/1.doc, c:/test/tutor/2.doc?
import java.io.*;
import java.util.*;
public class DocCapture {
public static void main(String [] args) throws IOException{
List<File> javaFiles = new ArrayList<File>();
File topDir = new File ("C:/Copy");
if (topDir.isDirectory())
javaFiles = getFiles(topDir);
System.out.printf("Found %d js files is directory %s and its sub-directories. ",javaFiles.size(), topDir.getName());
System.setOut(new PrintStream(new FileOutputStream ("C:/Copy/Location.txt")));
for (File f : javaFiles)
System.out.println("JSMinifier " + f.getPath() + " " + f.getPath() + " NOUI");
private static List<File> getFiles (File dir)
List<File> fileList = new ArrayList<File>();
File [] files = dir.listFiles();
for (int i = 0; i<files.length; i++) {
if(files.isDirectory())
fileList.addAll(getFiles(files[i]));
else if(files[i].getName().endsWith(".doc"))
fileList.add(files[i]);
String fileName = files[i].getName();
String name = "";
String ext = "";
try
name = fileName.substring(0, fileName.indexOf("."));
ext = fileName.substring(fileName.lastIndexOf("."), fileName.length());
if (ext.equals(".doc")) copy(files[i], new File("C:/Test/" + name + ext));
catch (IndexOutOfBoundsException e){
System.out.println(fileName + " has no extension");
return fileList;
public static void copy (File src, File dst){
try
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte [] buf = new byte [1024];
int len;
while ((len = in.read(buf))>0)
out.write(buf, 0, len);
in.close();
out.close();
System.out.println("File copied"+src.getPath()+dst.getPath());
catch (IOException e){
e.printStackTrace();
To copy source directory D to target directory D' recursively:
For every plain file in D
copy that file to D'
For every directory D2 in D
recursively copy D2 to its equivalent path D2' using this algorthm
Similar Messages
-
How can I copy a file with all attributes
Is there a way within Java to copy a file, with all its file attributes?
I have seen a number of custom methods posted on these forums for copying the contents of a file to a new file with the same name in another location. The problem is that these methods don't copy the file attributes, particularly the creation date.
If there is no way to do this in Java, is there a way to have Java execute an operating system command, such as "COPY" or to access the O/S to change the file attributes?
Thanks for any help you can provide.This is how runtime executes a batch file.
try {
Process p = Runtime.getRuntime().exec("cmd /c start c:\\batfile.bat");
p.waitFor();
} catch (Exception e) {
System.out.println(e.toString());
} -
How to copy the photo with file name at window 7 and search specific one in iphone 4s?
How to copy the photo with file name at window 7 and search specific one in iphone 4s?
Clendenen02 wrote:
2) It would be equally helpful if there was something that would take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments with the same name but obviously has different extention. For an example
In a Pictures folder
Name: Dark Knight, The.jpeg Comment: (2008) Genre: Action... <- copy comment
In a Movie Folder
Name: Dark Knight, The.m4v Comment: <- paste
and do this for all 700 files
This Bash script will do it.
Edit "PicDir" and "MovDir" to the location of your Folders
(Note: The comment is written to the m4v file using xattr, so the Spotlight comment field appears blank in Finder, but the comment metadata is still indexed by Spotlight (If you add a Spotlight comment from Finder, it is stored both as an extended attribute and in a .DS_Store file)
#!/bin/bash
PicDir=$HOME/Desktop/Pictures
MovDir=$HOME/Desktop/Movies
for f in $PicDir/*
do
if [ ! -d "$f" -a "${f##*.}" == "jpeg" ]; then
comment=$(mdls -raw -name kMDItemFinderComment "$f")
if [[ $comment != "(null)" ]]; then
picname=${f##*/}
movname=${picname%.*}.m4v
if [ -e "$MovDir"/$movname ]; then
xattr -w com.apple.metadata:kMDItemFinderComment "\"$comment\"" "$MovDir"/$movname
fi
fi
fi
done -
How to copy pdf files from computer to ipad
how to copy pdf files from computer to ipad
You can PDFs to the iPad, but first you need one or more apps on the iPad that supports PDFs - unlike a 'normal' computer the iPad doesn't have a file system, and everything on it has to be associated with an app.
Options include free apps such as Apple's iBooks app and also Adobe Reader - and paid-for apps such as GoodReader (which also supports read-only of other documents types).
For iBooks you can first add the PDFs to your computer's iTunes via File > Add To Library, and you can then sync them by selecting the iPad on the left-hand sidebar of your computer's iTunes (on iTunes 11 you can enable the sidebar via option-command-S on a Mac, control-S on a PC) and using the Books tab on the right-hand side to select and sync them.
For Adobe Reader adnd GoodReader you can use the file sharing on the Apps tab on the right-hand side to copy them over : http://support.apple.com/kb/ht4094 -
How to create pdf files with text field data
how to create pdf files with text field data
That looks like it should work, but it doesn't.
I opened the PDF I had created from Word in Acrobat (X Pro). Went to File > Properties. Selected "Change Settings". I then enabled "Restrict editing...", set a password, set "Printing Allowed" to "none", "Changes Allowed" to "none", and ensured that "Enable copying of text..." was disabled.
I saved the PDF file, closed Acrobat, opened the PDF in Reader, and I was still able to select text and graphical objects.
I reopened the PDF in Acrobat, and the document summart still shows everything as allowed. When I click on "show details" (from File > Properties) it shows the correct settings.
Any ideas? -
Copy a file with same filename using XI - module experts please help!
Guys,
Felix Jeyareuben had an excellent blog on how to copy a binary file with XI.
/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi
It is a shame by the way that such a simple thing has to be this complicated in XI, but that's another question...
So after I created the EAR file and successfully deployed the modules on our XI server, I got the following file adapter error, when I was trying to use it:
Sender Adapter v2727 for Party '', Service 'BS_TA_XI_DEV':
Configured at 2006-11-30 14:04:15 EST
History:
- 2006-11-30 14:10:00 EST: Error: java.lang.ClassCastException
- 2006-11-30 14:10:00 EST: Processing started
Can you give me any clues what could have gone wrong?
This is the first module I deployed so I might have messed up something simple, but I cannot figure this out.
Also how can I debug this?
Your help would be much appreciated.
Thanks a lot,
Viktor Varga> Moorthy,
> My issue is not so much about the filename, but an
> encrypted (binary) file that I just want to copy from here to there.
Do it like in the mentioned blog, but don't do any mapping. That will be fine.
> Michal,
> In my adapter I have the following:
> 1) localejbs/xi_file_module/ReadBinaryBean
> (LocalEnterpriseBean)
> ) localejbs/CallSapAdapter
> (LocalEnterpriseBean)
> ine.xml file I have this:
> <enterprise-bean>
> <ejb-name>ReadBinaryBean</ejb-name>
> <jndi-name>xi_file_module/ReadBinaryBean</jndi-name>
> <session-props/>
> enterprise-bean>
Check your EAR if there are any libs from the adapter framework and delete them if necessary.
After deployment check in your visual administrator if your EAR is available.
Regards
Stefan -
How could I delete files with name string with "TAL" and older than 05.05.
How could I delete files with name string with "TAL" and older than 05.05.2009 on unix
Our ECC Ides system today was not responsible. For first time 17 users were working on the systtem (IWN2008/SQL2005 based). Before the people were maximally 5.
The server is done by making a homogeneous system copy from an blade machine(now it is an VIrTUAL)
There was enaught disk space. However I checked Wokload 03sdn transaction) inn system. and found out that at that time of restarting(I had to restart system 3 times to get logged on the system and even then it was almost unresponsive.
I can found in there top abap."Login_Pw", "SESSION_MANAGER", "?". (BAtch), "ADMSBUF, >DEleyed Function call, RSPOWPOO""RSWWclear", ""VA01", "SAPMHHTP "Buf Sync" >DDLOC CLEANUP)""rsbtctE"
What can I do?
¸
Who could interfer SAP_CCMS_MONI_BATCH_DPSAP_CCMS_MONI_BATCH_DP
the 2 main users under users profile were ZUGTIN running and SAPSYS( running many system jobs)
How to approach the problem -
How to delete the file with space in name
Hi
I want to delete the file "test ex.txt" file.
i run the following command in command prompt.i can delete the file successfully.
/bin/rm -f /mnt/"test ex.txt"
I want to run the command from java.So i am using the following code
String cmd = "/bin/rm -f /mnt/\"test ex.txt\"";
Runtime rt = Runtime.getRuntime();
process = rt.exec(cmd);
The file was not deleted.
How to delete the file with space in name?
Help meUse the form of exec that takes an array of command + args.
arr[0] = "/bin/rm"
arr[1] = "-f"
arr[2] = "/home/me/some directory with spaces";Or use ProcessBuilder, which is the preferred replacement for Runtime.exec, and which Runtime.exec calls. -
How to open a file with the extension x3f (sigma)
how to open a file with the extension x3f (sigma)?
RAW data from the following Sigma cameras is currently supported:
DP1
DP1s
DP2
SD9
SD10
SD14
If your camera is among these, then simply import the photo as usual. https://helpx.adobe.com/lightroom/help/importing-photos-lightroom-basic-workflow.html -
How to validate xml file with XSD schema ?? in JDK1.4.2
How to validate xml file with XSD schema ?? in JDK1.4.2
i dont want to use new Xerec Jar ...
Suggest option ...Please do not double-post. http://forum.java.sun.com/thread.jspa?threadID=5134447&tstart=0
Then use Stax (Woodstock) or Saxon.
- Saish -
Does anyone know how to copy my files from my ipod to a different computer?
Does anyone know how to copy my files from my ipod to a different computer? I tried to do it, but all that it did was erase my files. What i want to to is use my ipod to transfer my files to another computer (which has itunes as well) PLEASE help!
You will need to enable your iPod for disk use. Then, you should see your iPod in "My Computer" and you can open up your iPod's folder there and drag the files into it. You can store the files on the iPod, then connect it to the other computer and drag-and-drop them from the iPod into the designated directory in that computer. Make sure individual files are not larger than 4 GB.
-
How to copy Log text (with Date, Time stamp ) User IDfrom BP to Transaction
Hi Experts,
Can someone guide us how to copy Log text (with Date ,Time & User ID) fron Business partner (Prospect) to transactions by text detrmination procedure.
Regards,
Basavaraj Patilsave text
Fill out following parameters of SAVE_TEXT function module:
HEADER
TDOBJECT C 10 BUT000
TDNAME C 70 10 digit BP number
TDID C 4 Z001
TDSPRAS C 1 Language
INSERT = X
LINES
TDFORMAT TDLINE
|
|testtttttttttttttttttttttttt( Your text)
I would suggest you to use some other BAPI that would attach your text to BP than SAVE_TEXT.
If you still wanted to use SAVE_TEXT then first make sure how the TDNAME is generated. It depends on the text determination procedure. For examples, it can be guid of BP, GUID followed by date or time or else the BP number itself.
Just go to BP transaction, double click on the text pad, it will open you the SAP Script editor. Click on menu GOTO and select Header which will give you info about your TDID, TDOBJECT, TDNAME....
Hope this helps. -
How should i share file with other devices such as nokia,blackberry and etc using bluetooth
I want to share files between other deivce such as nokia but couldnt, could u help me tell how can i share files with other devices???
@AKRBTN: Thanks for the reply and info.
That is a solution, but it really isn't viable.
It is sad that apple refuses to support this.
A simple example: Sitting somewhere with no signal and you want to share a file (photo) with your colleague or friend, who happens to be right next to you.
Or even if there is signal and you don't want to be paying fees or data charges.
Or you may be in a rehearsal studio and need to share that very important file and have no time to go outside and get signal and try to send the file, which then everyone else has to go outside and catch the signal and pay fees.
Anyway, I see that this is a dead end with apple, so I guess I will be back to carrying 2 phones around again.
Peace,
SB -
I have the same question in a different discussion but I already marked it as solved because one of the questions was answered. Here's the linke to the other discussion if your interested https://discussions.apple.com/thread/5970421
I have movie covers saved as a jpeg for every movie my family and I own. There is about 700 and they each have a comment of the main actors, release dates, and descriptions. This makes it easy to find what to watch.Is there an applescript, automator, program I can download, or program code supported in xcode that will do the following set of inscructions?
Take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments to a file with the same name but obviously has different extention. For an example
In a Pictures folder
Name: Dark Knight, The.jpeg Comment: (2008) Genre: Action... <- copy comment
In a Movie Folder
Name: Dark Knight, The.m4v Comment: <- paste
and do this for all 700 filesClendenen02 wrote:
where should I run the code? in the terminal, or an applescript, or should put it in xcode and run it from there or the terminal.
What MrHoffman said.
But if it's easier, you can wrap it in Automator and have Automator ask for the Folders: (Test on a sample of your files before running on all 700 files)
(do you really own 700 movies??)
The Workflow is:
Put this in the Run Shell Script Action (and pass input as arguments":
PicDir=$1
MovDir=$2
for f in $PicDir/*
do
if [ ! -d "$f" -a "${f##*.}" = "jpeg" ]; then
comment=$(mdls -raw -name kMDItemFinderComment "$f")
if [[ $comment != "(null)" ]]; then
picname=${f##*/}
movname=${picname%.*}.m4v
if [[ -e "$MovDir"/$movname ]]; then
osascript <<-EOF
tell application "Finder"
set comment of file (POSIX file "$MovDir/$movname") to "$comment"
end tell
EOF
fi
fi
fi
done
(BTW, I know that this is a bit of sloppy scripting (wraping an osascript in a Bash Script wrapped in Automator, but it does what you need) -
How to copy a file from one folder to another folder in Linux
Hello everyone,
Oracle forms 11g 11.1.2.0.0
OS: Oracle Linux
We use webutil to upload files to the application server from the client machine, and stores them in a folder named JOB_DOCS on the application server (This folder is created as a databse directory too). File types are JPEG, GIF, PDF, TXT, BMP, DOC, XLS etc...
At a later stage when the user tries to view the uploaded documents, this was not getting displayed on the screen
on our windows server, when the user clicks on the print button we copy the file from the JOB_DOCS folder to the forms\java folder using the below command
HOST('COPY ' ||d:\JOB_DOCS\test.pdf||' '||'c:\oracle\middleware\as\forms\java\test.pdf ,NO_SCREEN);
once the file is under the forms\java folder then it is getting displayed on the screen to print or save, and later we remove the file from forms\java folder.
But my problem here is, recently we have installed our application on Oracle Linux server, and we have JOB_DOCS folder there, and the users can upload files to this folder also. How can we copy the file test.pdf from JOB_DOCS to forms/java in linux?
And what could be the reson for the document cannot be accessed from the folder where it is saved? We tried giving folder permissions, adding the folder to PATH variable etc.For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you've already tried to copy a directory with cp, you've probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means "copy recursively":
$ cp -r dir1 dir2
The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1.
When renaming directories, you use the mv command exactly the same way as with files:
$ mv dir1 dir2
When dealing with directories, mv works a bit like cp does. If dir2 doesn't exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.
ref http://www.tuxfiles.org/linuxhelp/dirman.html
Maybe you are looking for
-
XI Scenarios (Views)
Guys, Need some u r views on below statements. 1) When i am using RFC Sender Adapter , i can only just give only static import paramters or else i can schedule it to background. So i understand that RFC Sender Adapter can be used when we want to u
-
Arbeiten mit Photoshop CS2 unter Windows Vista.
-
TabIndex not working in 2004 Pro
Hi, I'm trying to get my tabIndex set up to tab through a series of buttons within a movie clip on my _root timeline. I have a movie clip called "menuoptions" on the _root then within that I have a number of buttons called "menu1" etc. I have tried t
-
Different appearance of same file
Can anyone explain why the same PDF file viewed in Reader 8.1.2 on XPSP3 on two different laptops should look so different? I've posted side-by-side screenshots of an example at http://www.pixentral.com/show.php?picture=1oi6hYvQnhYXKGvG5GN7TiYgzURZ T
-
Object Type Handler (oth) issues in EP6 Stack 9. Anyone else have this?
We had some custom oth files in our EP5 SP6 portal that worked great for rendering files in a specific folder with our xsl stylehsheets. Now that we're moving to EP6 Stack 9, they don't work: They return a blank document of 0 content-size. I'm wonder