I'd like to Create a New Text Document in the Current Directory, named "New Text Document" that is created with the text Highlighted for Renaming, the same as if you right-click the open folder > New >Text Document
I'd prefer to do it straight from the Command Line, or if not possible, then a Batch Script
I'd like to just point to %windir%\System32\notepad.exe and make it create a new Document in the current folder, or maybe somehow launch it from the Current Directory somehow..
or I thought about creating a file called "New Text Document.txt" elsewhere on the computer, and maybe pointing to that file, and copying it to the current directory.. but I'd like it to go straight to renaming.
anyone know if thats possible or not?
thanks
Try this:
echo 2> NewTextDocument.txt
This will redirect any error to NewTextDocument.txt.
Since this command is valid (no error), it will produce new file with empty content.
More about redirecting: wikipedia
Related
How do I fix this on Mac?
Unable to save /test.py Error: Read-only file system
Since Mojave, you are no longer allowed to write to /. I suspect this is the cause of your problem: nothing to do with Sublime Text.
Pick another directory to save your files to, preferably in your home folder.
Once you make your document, go to File and click Save (or just press cmd+n).
Write the title of your document.
Right under the name there should be a little box that says Macintosh. You can click on it and change it to whatever file you prefer.
you must have left the save location as "macintosh". Basically this error means, that this "macintosh" folder is read-only. There is no issue like "sublime not having permission to write to the disk".
Just save to a usual folder and you would be gtg.
Make sure you save it to your project's folder and not just to the desktop or whatever is the default.
I thought VS Code saves all the relevant metadata in .vscode folder and .code-workspace file and as these are contained within the workspace folder I assumed it's all self-contained and shouldn't cause problems when moved. But apparently I was gravely mistaken.
After moving my workspace folder to a new location and altering folder paths saved in .code-workspace file accordingly all my opened editor panes and the bottom panel are gone. What I have now is a nice Welcome window.
I'm aware of what the official guide recommends, but that's only moving .code-worskpace metafile - the folder still stays in place.
I've just run into the same issue. My workspace wasn't saved to a file at all (I just use the "Open with Code" option on each project folder), and the Save Workspace As option didn't help as it just created a JSON file with a couple of empty objects in it (which probably makes sense as I haven't really modified any workspace settings, I just want to preserve my open editors and things like that).
On Windows at least, it seems that those kinds of "workspace" settings are actually stored within subfolders of %APPDATA%\Code\User\workspaceStorage, and an SQLite database file is used to store the actual settings, so this is what I ended up doing:
Move your folder to the new location on disk (close all VS Code windows first)
Open the new folder location with VS Code (you'll just get the Welcome tab at this stage, but we just need it to create a settings storage folder for the new location). Then close VS code again.
Open %APPDATA%\Code\User\workspaceStorage in File Explorer, go into each subfolder and open workspace.json (in any old text editor). In my case at least, it only contains a folder property, which is path of the folder that this settings folder relates to (but just changing this won't help us at all, it was the first thing I tried). Use this to figure out which of these subfolders relate to the old and new paths.
Copy state.vscdb from old to new, and delete state.vscdb.backup in new.
Open state.vscdb in new in some sort of SQLite database file editor (I used DB Browser for SQLite and it worked fine, but there's also SQLiteStudio which looks like it might be better in general).
Run an UPDATE query to update all the paths in the database. They seem to be stored in three different formats/levels of escaping - between folders there can be a forward slash, two backslashes, or four backslashes. In my case I wanted to move my project folder from the root of my Windows user folder into my usual documents folder which is within OneDrive, so my query was along the lines of the following, as I only needed to change the middle section of each path. You might have to do something more complicated if you are moving to a different drive for example (would need to have a look at all the existing paths in the database to see how they are encoded).
UPDATE `ItemTable` SET `value` = REPLACE(REPLACE(REPLACE(`value`, 'User/Project', 'User/OneDrive/Documents/Project'), 'User\\Project', 'User\\OneDrive\\Documents\\Project'), 'User\\\\Project', 'User\\\\OneDrive\\\\Documents\\\\Project')
After saving the database, I just opened the new folder in VS Code, and everything seems to have loaded up exactly as it was in the old location :)
(Also just in case anyone is curious, the subfolder names in workspaceStorage seem to be some sort of hash based on the path, because if you delete the subfolder that relates to a folder you've previously opened in VS Code and then open that folder in Code again, it recreates the same subfolder name. So that means just updating the old workspace.json and database file in-place won't work)
Scenario 1 - Moving the .code-workspace file The xxx.code-workspace file that defines your project folder location(s) is in JSON format. It has a "folders" section and a "settings" section. If you just mant to move the location of the xxx.code-workspace all that is needed is to go to File->Save Workspace As..., browse to the new location, select the name you want to give the workspace and it will save it with a .code-workspace extension. All of the "path" entries in the "folders" section are changed to a path relative to the new location.
Scenario 2 - Moving the entire workspace. If you want to move the entire workspace to a new location and the .code-workspace file is in the root directory of your workspace, just move the old workspace to the new location. The contents of the .code-workspace file will still be correct. Just select File->Open Workspace..., navigate to the new location and open the .code-workspace file.
Scenario 3 - When you .code-workspace folder is stored in a different location. If you store all of your .code-workspace files in a location apart from the actual workspace, the simplest way to move the workspace is a two step process:
With your workspace open, do File->Save Workspace As... and save the .code workspace file to the root directory of your workspace.
Move the workspace to the new location.
File->Save Workspace As... and save the .code workspace file to its location.
Close VS Code and delete the .code-workspace folder that's in the root directory of your resource, so that future settings changes will be saved to the correct workspace.
I have installed LXDE on my Ubuntu PC (not Lubuntu). I want to change the text in the logout session. The default text is "Logout LXDE session ?". But I want to personalize it. I've already changed the picture of the logout session. Can you help me? Thank you very much.
BowStar
I don’t know yet how to solve this in a completely and permanent way, but you can create a new logout dialogue box:
Make a Folder and, inside it, click with the right mouse button to create a new empty file (a simply txt file) with the name "temp-lubuntu-logout" (you can change the file name after the conclusion of the work.
Paste this text, changing the items to fit your options:
!/bin/sh
lxsession-logout --prompt "Your custom message" --banner "Your logo" \
--side "left | top | right | bottom (The position of the logo)"
Open with the terminal the folder where is your temp-lubuntu-logout file and make it executable with this command:
sudo chmod +x temp-lubuntu-logout
That’s all! You just created a script file!
To verify is it is working, write in the terminal:
./temp-lubuntu-logout
(dont forget the dot before the /)
Now I can’t help more them this. You need to link this script to the the command of a app. Or you can change the lubuntu-logout script with your new script file (you may, for example, rename the original script to "former-lubuntu-logout" and your file to "lubuntu-logout". Probably, the path to the "lubuntu-logout" file is /usr/bin).
https://crisnepita.wordpress.com/2012/08/12/cambiar-un-poco-la-ventana-de-cerrar-sesion-en-lubuntu/
https://unix.stackexchange.com/questions/170029/command-to-log-out-of-lxde-directly/171880
http://tunealxde.blogspot.pt/2015/02/tunea-el-dialogo-de-cierre-de-sesion-de.html
I have found a way to change it.
Warning
This requires you to know what you are doing.
Use your favorite hex editor and edit file /usr/bin/lxsession-logout
Scroll all the way down the file, then go up until you see a human-readable section.
Over there, on a long string, there is the logout menu in bytes.
Once you change stuff in there, and save the binary, if you did not break something it will work. For deleting something, just overwrite its section with spaces, same for text and labels.
Tip: only edit and don't change any appearance order or add more bytes at some index because it will scramble the offset table of the file and will become corrupted.
Edit: Oops my bad! I wasn't clear enough... I guess I need to explain more...
I need to create a package installer for my customers. I want them to extract and overwrite the contents only in their specific folder.
I don't want them to be able to extract the contents wherever they want to let them steal my work /or know what my files are all about.
So I was thinking maybe the installer could be created in a way to check for a file name inside the folder and after the file name has been recognized then it can be simply extracted and overwritten and if not then the operation will be cancelled.
Any Idea ?
Assuming you're running Windows...If the file name is recognised in the specified extraction folder, then it'll prompt you to either overwrite or cancel. - Either using Window's own extractor or something like 7Zip will achieve this.
Okay, so I believe this might help:
https://superuser.com/questions/259353/7-zip-windows-7-make-extract-to-folder-default-on-double-click
Particularly Haiggoh's comment:
1.Start regedit as administrator
2.Open HKEY_CLASSES_ROOT\7-Zip.7z
3.Under that key, expand the Shell sub-key
4.Set the (Default) value to the string extract
5.Create a new sub-key named extract
6.Set the (Default) value for the extract key to Extract to Folder
7.Create a new sub-key under extract named command
8.Set the (Default) value of the command key to:
C:\ProgramFiles\7-Zip\7zG.exe x "%1" -o* (you might have to a adjust
this to match the path of you 7zip installation)
Instead of 7z with -aou like Justin Roettger suggested I ended up
using 7zG, because this way you can choose to overwrite if you like
just like extracting with the normal context menu.
That's it! 7z files are now extracted to a folder with their own name
by double click. For other extensions like .rar and .zip you need to
repeat these steps for the according keys. (i.e.
HKEY_CLASSES_ROOT\7-Zip.rar and HKEY_CLASSES_ROOT\7-Zip.zip and so on)
Oh and to clarify: It does work with multiple files selected as well.
No batch file need.
Have a read through the above and hopefully it'll point you in the right direction.
I've written a vary basic shell script that moves a specified file into the dustbin directory. The script is as follows:
#!/bin/bash
#move items to dustbin directory
mv "$#" ~/dustbin/
echo "File moved to dustbin"
This works fine for me, any file I specify gets moved to the dustbin directory. However, what I would like to do is create a new script that will move the file in the dustbin directory back to its original directory. I know I could easily write a script that would move it back to a location specified by the user, but I would prefer to have one that would move it to its original directory.
Is this possible?
I'm using Mac OS X 10.6.4 and Terminal
You will have to store where the original file is coming from then. Maybe in a seperate file, a database, or in the files attributes (meta-data).
Create a logfile with 2 columns:
The complete filename in the dustbin
The complete original path and filename
You will need this logfile anyway - what will you do when a user deleted 2 files in different directories, but with the same name? /home/user/.wgetrc and /home/user/old/.wgetrc ?
What will you do when a user deletes a file, makes a new one with the same name, and then deletes that too? You'll need versions or timestamps or something.
You need to store the original location somewhere, either in a database or in an extended attribute of the file. A database is definitely the easiest way to do it, though an extended attribute would be more robust. Looking in ~/.Trash/ I see some, but not all files have extended attributes, so I'm not sure how Apple does it.
You need to somehow encode the source directory in the file. I think the easiest would be to change the filename in the dustbin directory. So that /home/user/music/song.mp3 becomes ~/dustbin/song.mp3|home_user_music
And when you copy it back your script needs to process the file name and construct the path beginning at |.
Another approach would be to let the filesystem be your database.
A file moved from /some/directory/somewhere/filename would be moved to ~/dustbin/some/directory/somewhere/filename and you'd do find ~/dustbin -name "$file" to find it based on its basename (from user input). Then you'd just trim "~/bustbin" from the output of find and you'd have the destination ready to use. If more than one file is returned by find, you can list the proposed files for user selection. You could use ~/dustbin/$deletiondate if you wanted to make it possible to roll back to earlier versions.
You could do a cron job that would periodically remove old files and the directories (if empty).