{"id":211,"date":"2011-05-15T22:03:22","date_gmt":"2011-05-15T22:03:22","guid":{"rendered":"https:\/\/blog.alwawee.ru\/?p=211"},"modified":"2011-07-06T13:13:15","modified_gmt":"2011-07-06T13:13:15","slug":"creation-of-files-in-a-given-folder-programmatically-using-visual-basic-script-vbscript","status":"publish","type":"post","link":"https:\/\/blog.alwawee.ru\/?p=211","title":{"rendered":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript)"},"content":{"rendered":"<p>If a user must create, for instance, 20 files with names 1.tex, 2.tex, 3.tex, &#8230;, 20.tex, he will probably do it manually. Even the use of Total Commander with its hot key Shift+F4 for creation of files will not save you from the boring and stupid work. But a programmer is not a user and you can write the following Visual Basic Script (VBScript) with file name, for example, &#8220;CreateFilesScript.vbs&#8221;.<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<code><br \/>\n'(C) Author: Denis Kutlubaev, Alwawee Company, Moscow, 2011<br \/>\n'This script creates files with names 25.tex to 36.tex in a given folder<br \/>\n'folderPath - path to folder where files must be created<br \/>\n'fileName - generated file name<br \/>\n'filePathAndName - generated full path and file name<br \/>\n'start and stopIndex - numbers to start and stop file naming and creation<\/p>\n<p>Dim folderPath, fileName, filePathAndName<br \/>\nDim fileNumber, i<br \/>\nSet FSO = CreateObject(\"Scripting.FileSystemObject\")<\/p>\n<p>folderPath = \"c:\\Documents and Settings\\wzbozon\\\u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u0442\u043e\u043b\\LaTeX\\Lessons\\\"<\/p>\n<p>For i = 25 To 36<br \/>\nfileNumber = i<br \/>\nfileName = CStr(fileNumber) &amp; \".tex\"<br \/>\nfilePathAndName = folderPath &amp; fileName<br \/>\nFSO.CreateTextFile(filePathAndName)<br \/>\nNext<br \/>\n<\/code><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>It is noteworthy that in Visual Basic Script there are some restrictions. For example, the loop<br \/>\n<code><br \/>\nFor i = 25 To 36<br \/>\n<\/code><br \/>\ncannot be unhardcoded. <\/p>\n<p>Also, you cannot define step for loop, it is always 1. <\/p>\n<p>In this line<br \/>\n<code><br \/>\nfileName = CStr(fileNumber) &amp; \".tex\"<br \/>\n<\/code><br \/>\nthere is a concatenation of a string, produced by CStr operator from a number and a file extension.<\/p>\n<p>If you write a VBScript, you will wish to debug it. To debug it, write in a command line: <code><br \/>\nwscript \/\/X CreateFilesScript.vbs<\/code><br \/>\nAfter this you can choose Visual Studio as a default debugger for VBScript and you will catch the line, where the script fails. Unfortunately, without much information about the bug.<\/p>\n<p>Some useful links: <\/p>\n<ol>\n<li> <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/te2585xw(v=vs.80).aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/te2585xw(v=vs.80).aspx<\/a> &#8211; Concatenation of strings in VBScript<\/li>\n<li><a href=\"http:\/\/www.tizag.com\/vbscriptTutorial\/vbscriptforloop.php\">http:\/\/www.tizag.com\/vbscriptTutorial\/vbscriptforloop.php<\/a> &#8211; Loops in VBScript<\/li>\n<li><a href=\"http:\/\/www.script-coding.com\/\">http:\/\/www.script-coding.com\/<\/a> &#8211; Good source for script writing (in Russian)<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>If a user must create, for instance, 20 files with names 1.tex, 2.tex, 3.tex, &#8230;, 20.tex, he will probably do it manually. Even the use of Total Commander with its hot key Shift+F4 for creation of files will not save you from the boring and stupid work. But a programmer is not a user and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-android"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.alwawee.ru\/?p=211\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev\" \/>\n<meta property=\"og:description\" content=\"If a user must create, for instance, 20 files with names 1.tex, 2.tex, 3.tex, &#8230;, 20.tex, he will probably do it manually. Even the use of Total Commander with its hot key Shift+F4 for creation of files will not save you from the boring and stupid work. But a programmer is not a user and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.alwawee.ru\/?p=211\" \/>\n<meta property=\"og:site_name\" content=\"Denis Kutlubaev\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/alwaweemobile\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-15T22:03:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-07-06T13:13:15+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/blog.alwawee.com\/?attachment_id=1982\" \/>\n<meta name=\"author\" content=\"Denis Kutlubaev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Denis Kutlubaev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211\"},\"author\":{\"name\":\"Denis Kutlubaev\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"headline\":\"Creation of files in a given folder programmatically using Visual Basic Script (VBScript)\",\"datePublished\":\"2011-05-15T22:03:22+00:00\",\"dateModified\":\"2011-07-06T13:13:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211\"},\"wordCount\":227,\"commentCount\":0,\"articleSection\":[\"Android\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211\",\"name\":\"Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\"},\"datePublished\":\"2011-05-15T22:03:22+00:00\",\"dateModified\":\"2011-07-06T13:13:15+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=211#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.alwawee.ru\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creation of files in a given folder programmatically using Visual Basic Script (VBScript)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/\",\"name\":\"Denis Kutlubaev\",\"description\":\"iOS Development\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.alwawee.ru\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\",\"name\":\"Denis Kutlubaev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"caption\":\"Denis Kutlubaev\"},\"description\":\"iOS Developer, creator of Tornado Browser and many other popular apps\",\"sameAs\":[\"http:\\\/\\\/dennis.alwawee.com\"],\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.alwawee.ru\/?p=211","og_locale":"en_US","og_type":"article","og_title":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev","og_description":"If a user must create, for instance, 20 files with names 1.tex, 2.tex, 3.tex, &#8230;, 20.tex, he will probably do it manually. Even the use of Total Commander with its hot key Shift+F4 for creation of files will not save you from the boring and stupid work. But a programmer is not a user and [&hellip;]","og_url":"https:\/\/blog.alwawee.ru\/?p=211","og_site_name":"Denis Kutlubaev","article_publisher":"https:\/\/www.facebook.com\/alwaweemobile","article_published_time":"2011-05-15T22:03:22+00:00","article_modified_time":"2011-07-06T13:13:15+00:00","og_image":[{"url":"http:\/\/blog.alwawee.com\/?attachment_id=1982","type":"","width":"","height":""}],"author":"Denis Kutlubaev","twitter_misc":{"Written by":"Denis Kutlubaev","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.alwawee.ru\/?p=211#article","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/?p=211"},"author":{"name":"Denis Kutlubaev","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"headline":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript)","datePublished":"2011-05-15T22:03:22+00:00","dateModified":"2011-07-06T13:13:15+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.alwawee.ru\/?p=211"},"wordCount":227,"commentCount":0,"articleSection":["Android"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.alwawee.ru\/?p=211#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.alwawee.ru\/?p=211","url":"https:\/\/blog.alwawee.ru\/?p=211","name":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript) - Denis Kutlubaev","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/#website"},"datePublished":"2011-05-15T22:03:22+00:00","dateModified":"2011-07-06T13:13:15+00:00","author":{"@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"breadcrumb":{"@id":"https:\/\/blog.alwawee.ru\/?p=211#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.alwawee.ru\/?p=211"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.alwawee.ru\/?p=211#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.alwawee.ru\/"},{"@type":"ListItem","position":2,"name":"Creation of files in a given folder programmatically using Visual Basic Script (VBScript)"}]},{"@type":"WebSite","@id":"https:\/\/blog.alwawee.ru\/#website","url":"https:\/\/blog.alwawee.ru\/","name":"Denis Kutlubaev","description":"iOS Development","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.alwawee.ru\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7","name":"Denis Kutlubaev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","caption":"Denis Kutlubaev"},"description":"iOS Developer, creator of Tornado Browser and many other popular apps","sameAs":["http:\/\/dennis.alwawee.com"],"url":"https:\/\/blog.alwawee.ru\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":0,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}