forked from npocmaka/batch.scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellCopy.bat
More file actions
62 lines (47 loc) · 1.44 KB
/
Copy pathshellCopy.bat
File metadata and controls
62 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
cscript //E:JScript //nologo "%~f0" "%~nx0" %*
exit /b %errorlevel%
***** end comment *********/
var FSOObj = new ActiveXObject("Scripting.FileSystemObject");
var ShellObj=new ActiveXObject("Shell.Application");
var ARGS = WScript.Arguments;
var scriptName=ARGS.Item(0);
var move = false;
if (ARGS.Length == 0 ) {
WScript.Echo("Uses shell.application to move/copy files. Usage:");
WScript.Echo(scriptName + "source destinationDirectory [move]");
WScript.Echo("Example:");
WScript.Echo("call " + scriptName + "\"C:\\file.txt\" \"D:\\folder\" ");
WScript.Echo("To move files:");
WScript.Echo("call " + scriptName + "\"C:\\*.txt\" \"D:\\folder\" yes");
WScript.Quit(0);
}
if (ARGS.Length < 3 ) {
WScript.Echo("ERROR: not enough arguments");
WScript.Quit(1);
}
if (ARGS.Length > 3 ) {
if (ARGS.Item(3).toLowerCase() == "true") {
move = true;
}
}
var source = ARGS.Item(1);
var destination = ARGS.Item(2);
//options values
var YES_TO_ALL=16;
var YESTA_NEW_NAMES=312
getFullPath = function (path) {
return FSOObj.GetAbsolutePathName(path);
}
destination = getFullPath(destination);
if (!FSOObj.FolderExists(destination)) {
WScript.Echo("ERROR: directory " + destination + " does not exists");
WScript.Quit(1);
}
var folder = ShellObj.NameSpace(destination);
if (move) {
folder.MoveHere(source,YESTA_NEW_NAMES);
} else {
folder.CopyHere(source,YESTA_NEW_NAMES);
}