Created
September 20, 2013 19:39
-
-
Save servel333/6642752 to your computer and use it in GitHub Desktop.
Small Ruby script to generate a Notepad++ workspace from a path recursively.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this.rb c:/path/to/scan > npp.workspace.xml | |
def puts(*args) | |
Kernel.puts *args | |
end | |
def scan_path(parent, indent='') | |
paths = Dir.glob(File.join(parent, '*')) | |
paths.select{ |path| !File.directory? path }.sort.each do |file| | |
puts indent+'<File name="'+file+'" />' | |
end | |
paths.select{ |path| File.directory? path }.sort.each do |directory| | |
filename = File.basename(directory) | |
puts indent+'<Folder name="'+filename+'">' | |
scan_path directory, indent+' ' | |
puts indent+'</Folder>' | |
end | |
end | |
if (ARGV[0].nil?) | |
abort 'Path required' | |
end | |
root = ARGV[0] | |
puts '<NotepadPlus>' | |
puts ' <Project name="'+root+'">' | |
scan_path(root, ' '); | |
puts ' </Project>' | |
puts '</NotepadPlus>' | |
#<NotepadPlus> | |
# <Project name="Project name (can be any string)"> | |
# <Folder name="folder name (can be any string)"> | |
# <Folder name="folder name (can be any string)"> | |
# <File name="full path to file" /> | |
# </Folder> | |
# </Folder> | |
# </Project> | |
#</NotepadPlus> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment