Moving files from one directory and appending a date to the file name to another directory
Date : March 29 2020, 07:55 AM
With these it helps This will append the date (_YYYYMMDD) to all .SQL files in the E:\Scripts\ directory, then move them to the E:\Scripts\OBIEE\ subfolder. @echo off
cd E:\Scripts\
set cur_yyyy=%date:~10,4%
set cur_mm=%date:~4,2%
set cur_dd=%date:~7,2%
for /f %%f in ('dir /b *.sql') do (
rename %%f %%~nf_%cur_yyyy%%cur_mm%%cur_dd%%%~xf
move %%~nf_%cur_yyyy%%cur_mm%%cur_dd%%%~xf ./OBIEE/
)
|
Moving file with Java changes directory to .eml
Date : March 29 2020, 07:55 AM
it helps some times The target in Files.move(source, target, options) is the actual target of the move. With REPLACE_EXISTING your call will remove the existing target (your directory) and then move the source to that name. A directory will only be removed if it's empty*, otherwise the call with throw a DirectoryNotEmptyException. public void moveFile(String source, String targetDir)
{
Path dirpath = Paths.get(targetDir);
if (Files.exists(dirpath)) {
Path target = dirpath.resolve(targetDir);
try {
Files.move(Paths.get(source), dirpath.resolve(target), REPLACE_EXISTING);
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
new File(targetDir).mkdir();
moveFile(source, targetDir);
}
}
|
Java - Moving all sub-directory files to Parent Directory
Tag : java , By : Valentine
Date : March 29 2020, 07:55 AM
this one helps. I am trying to move all files I have stored in a sub-directories to the Parent Directory they all belong to. private static void move(File toDir, File currDir) {
for (File file : currDir.listFiles()) {
if (file.isDirectory()) {
move(toDir, file);
} else {
file.renameTo(new File(toDir, file.getName()));
}
}
}
|
Moving a file from a directory to home directory using shell script, it works as a standalone command(as in outside the
Tag : shell , By : George H.
Date : March 29 2020, 07:55 AM
Any of those help Could you be running into the issue from this answer with expanding the user's home directory? What happens if you write your script like this: #!/bin/bash
# Other tasks to retrieve summary.html done here
mv ./summary.html $HOME/public_html/chats/
exit 0
|
Moving a directory in java throws java.nio.file.FileAlreadyExistsException
Tag : java , By : Brownell
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Figured out the issue. In my code before doing a rollback, I am doing a backup, in that method I am using this section to do the copy if (Files.exists(Paths.get(contentPath)) && Files.list(Paths.get(contentPath)).count() > 0) {
copyPath(Paths.get(contentPath), Paths.get(tmpContentPath));
try (Stream<Path> fileList = Files.list(Paths.get(contentPath))) {
if (Files.exists(Paths.get(contentPath)) && fileList.count() > 0) {
copyPath(Paths.get(contentPath), Paths.get(tmpContentPath));
}
}
|