I wrote this VBS script to copy “Date Modified” from files in one folder to another but have one query ...
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
How can I make names more distinctive without making them longer?
How do I stop a creek from eroding my steep embankment?
Sci-Fi book where patients in a coma ward all live in a subconscious world linked together
Do I really need recursive chmod to restrict access to a folder?
Why do we bend a book to keep it straight?
Error "illegal generic type for instanceof" when using local classes
Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?
Short Story with Cinderella as a Voo-doo Witch
Fundamental Solution of the Pell Equation
Is there a (better) way to access $wpdb results?
Why is "Consequences inflicted." not a sentence?
What does this icon in iOS Stardew Valley mean?
Overriding an object in memory with placement new
Coloring maths inside a tcolorbox
English words in a non-english sci-fi novel
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
A coin, having probability p of landing heads and probability of q=(1-p) of landing on heads.
How come Sam didn't become Lord of Horn Hill?
porting install scripts : can rpm replace apt?
Can an alien society believe that their star system is the universe?
The logistics of corpse disposal
ListPlot join points by nearest neighbor rather than order
How to find all the available tools in macOS terminal?
I wrote this VBS script to copy “Date Modified” from files in one folder to another but have one query
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Executables in Windows 7 Giving Profane Error MessageVBscript process disappearsHow do I associate a file type with a VBScriptCopy all files from a list of folder locationsRun a scheduled task that can update the desktop background wallpaper without causing a foreground flash?VBS Replace characters from filenames of all files in folder and subfoldersLocked or ghost file created when a file is moved or deleted
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I wrote this VBS code to copy "Date Modified" from files in one folder to another folder.
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, oShell
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:UsersasdDesktopDestination")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
sOriginFolder = "C:UsersasdDesktopSource"
sDestinationFolder = "C:UsersasdDesktopDestination"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
Set objFolderItem = objFolder.ParseName(oFSO.GetFileName(sFile))
objFolderItem.ModifyDate = FormatDateTime(sFile.DateLastModified,0)
Next
It works but there is one issue.
If the extension of the file is different, then the script crashes.
How can I fix this?
vbscript
add a comment |
I wrote this VBS code to copy "Date Modified" from files in one folder to another folder.
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, oShell
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:UsersasdDesktopDestination")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
sOriginFolder = "C:UsersasdDesktopSource"
sDestinationFolder = "C:UsersasdDesktopDestination"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
Set objFolderItem = objFolder.ParseName(oFSO.GetFileName(sFile))
objFolderItem.ModifyDate = FormatDateTime(sFile.DateLastModified,0)
Next
It works but there is one issue.
If the extension of the file is different, then the script crashes.
How can I fix this?
vbscript
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago
add a comment |
I wrote this VBS code to copy "Date Modified" from files in one folder to another folder.
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, oShell
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:UsersasdDesktopDestination")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
sOriginFolder = "C:UsersasdDesktopSource"
sDestinationFolder = "C:UsersasdDesktopDestination"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
Set objFolderItem = objFolder.ParseName(oFSO.GetFileName(sFile))
objFolderItem.ModifyDate = FormatDateTime(sFile.DateLastModified,0)
Next
It works but there is one issue.
If the extension of the file is different, then the script crashes.
How can I fix this?
vbscript
I wrote this VBS code to copy "Date Modified" from files in one folder to another folder.
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, oShell
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace("C:UsersasdDesktopDestination")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
sOriginFolder = "C:UsersasdDesktopSource"
sDestinationFolder = "C:UsersasdDesktopDestination"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
Set objFolderItem = objFolder.ParseName(oFSO.GetFileName(sFile))
objFolderItem.ModifyDate = FormatDateTime(sFile.DateLastModified,0)
Next
It works but there is one issue.
If the extension of the file is different, then the script crashes.
How can I fix this?
vbscript
vbscript
edited 19 hours ago
user5793353
asked yesterday
user5793353user5793353
83
83
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago
add a comment |
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1425819%2fi-wrote-this-vbs-script-to-copy-date-modified-from-files-in-one-folder-to-anot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1425819%2fi-wrote-this-vbs-script-to-copy-date-modified-from-files-in-one-folder-to-anot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What extensions does it work on, and what does it not work on?
– music2myear
yesterday
It takes the first file name from the source folder and takes its date modified. It takes the first file name from the destination folder and if their names match, it pastes the date modified onto it. Then it will take the second file and do the same. But if the extensions are different, then the program crashes with 'type mismatch'.
– user5793353
19 hours ago