Opening all files of a certain filetype in vscode - visual-studio-code

For my website, I have one "root" folder with a bunch of subfolders containing many different types of files. Example:
root folder
subfolder
subfolder
HTML file
other files...
subfolder
HTML file
other files...
Many of these subfolders have HTML files in them. I am wondering if there are any commands I can run to open all of the HTML files in vscode, or of any filetype for that matter.
I am aware that cmd+control+p allows the selection of a specific file by search, but is there any modification of that for all files of a file type? It is probably possible to write a bash script to do this, but I am not well versed in bash and I am wondering if there are any built-in ways to do this on vscode or plugins I can install to do this.
It also should be noted I am on a mac.

Here's on option to find all files that match a given filename specification (in*.html in my example) and send that list of files to VS Code via xargs:
find . -iname "in*\.html" -print0 | xargs -0 code

Related

Generate Localizable.strings file based on occurrences of NSLocalizedString in codebase Swift

I have a codebase were I've used NSLocalizedString everywhere. I now want some kind of script or tool that finds all these NSLocalizedString and formats a Localizable.strings file. Does this exist? I'd hate to have to do this manually.
1
You can use genstrings as #Extra Savoir-Faire noted.
Create a file names en.lproj in the root directory of your project.
cd into the project from the terminal.
Run this command find ./ -name "*.swift" -print0 | xargs -0 genstrings -o en.lproj
This should export all files ending with swift that have a NSLocalizedString.
Also you can have the en.lproj anywhere as long as you run this command in the it's parent directory (you can see it when run the ls command
2
You can also export the file directly from Xcode.. the .strings file.
Open your project in Xcode
Select Product
Select Export Localizations
Select the desired package
Select location and export.
When you go to the folder you exported. You will find the Localizable.strings in
en.xcloc -> Source Contents -> YourProjectName-> en.lproj
You can use the Localizable.strings from there.
I've used this app before to do what you’re asking about: http://linguanapp.com.
Per Apple's documentation:
Although you can create strings files manually, it is rarely necessary
to do so. If you write your code using the appropriate string-loading
macros, you can use the genstrings command-line tool to extract those
strings and create strings files for you.

How to rename files in VS Code in bulk?

Is there a way to search for ALL .txt files in a project and automatically replace/rename them to .js?
E.g user.txt to user.js
It seems I can't search for a file format in VS Code.
If you know how, please share!
You could just do it in the terminal.
mv *.txt *.js
You can use a combination of:
Filtering the EXPLORER panel to just show .txt files
See "Filtering the document tree" section of the VS Code docs
See related Stack Overflow post: "Filter files shown in Visual Studio Code"
Installing and using the Batch Rename extension
For example, given these files/folders:
Steps:
Start by clicking on the EXPLORER panel and filtering to just display .txt files
Select/highlight all the files, then right-click on any selected file, then select "Batch Rename"
That would open a text file ".Batch Rename.txt" with all the selected files
Do a regular find-and-replace to change .txt to .js
Note that the ".Batch Rename.txt" is unsaved. It's like a preview of what the changes would look like
Save ".Batch Rename.txt" and it will automatically close
The EXPLORER panel should now be empty since it's filtered on .txt
Remove the filter and the files should now be renamed
You can use find to do this in a terminal recursively.
find . -iname "*.txt" -exec rename .txt .js '{}' \;
refer Find multiple files and rename them in Linux
mv works if you want to just do it in a folder itself.
Old question, I know, but for you or anyone else coming in, if you're okay with using a non-VS Code solution, there's a GUI Windows tool called RegexRenamer that is so well-named, you already know what it does.
It gives you a preview of what the renamed files will look like, and has options to rename everything in subfolders or only the current folder, ignore/include file extensions in the search, and apply the rename only to folders/files or both.
What do you think?

Run exiftool across all file types

I am using exiftool to recursively search across directories containing hundreds of files. At present, it is returning the results to a .csv file. Manually comparing my results, there are some files within the target directory that do not have a valid file extension. Nonetheless, when examining the raw data (or adding .jpeg as the extension), the files are indeed image files.
Is there any way to force exiftool to process all files regardless of what the file extension is or indeed whether it has a file extension?
Thanks
You will want to use the -ext option.
Add -ext "*" to your command to process all files.

Ctags not working with .inc-files

I would love to use tags inside Emacs, like Vim does. However, I have some problems to set it ## Setup:
GNU Emacs GUI version 25.0.5.1 (x86_64-w64-mingw32)
Compiled from Harroogan Emacs.
Projectile and Helm, using the latest version of Projectile/Helm from MELPA
Exuberant Ctags binary 58 for Windows
Windows 7 x64 bit.
Actions:
The binary ctags.exe is in the PATH, and respons when I call it from command line in Windows with ctags --help.
I tried various things to create a TAGS file, without any result. One thing that I seem to have results, is with the help of the package projectile. But it gives me weird results.
When I'm inside a project, currently the buffer index.php is being opened. Inside that buffer, I regenate tags file with projectile-regenate-tags, with C-c p R.
The messages buffer gives me the following:
Starting a new list of tags tables
Making tags-file-name local to Dev/digiloket3/TAGS while let-bound!
I see the file TAGS is being created in the project root.
The directory root structure is like this:
index.php
.projectile
|- INCLUDE
|- AJAX
|- SCRIPTS
|- PHP
Issue:
Then I visit the tag list with find-tag (g C-]). When I notice I don't get all variables and class/functions that are defined in the project.
When I call the helm-etags-select, I see the directory/file next to the tag. And what confuses me, is that only functions/classes and variables from files in the directory AJAX are being visible in the tag list, and not the variables/classes/functions from the files in the directory PHP.
Then I manually creating the TAGS file with in the command prompt with the right directory on ctags -R.
With no help.
All files in the folder PHP are called ****.inc.
When I renamed one of the files to ****.php, then they're popping up in my ctags table.
So the real issue here is how I could tell projectile/ctags to recognize .inc files as PHP-files, or index it
But I'm also open for another things to create a TAGS table on Windows platform with the ctags available on command line.
Any suggestion?
man ctags for starters (if you can do so in Windows? There is documentation available in any case.)
Assigning file extensions for a language is done with --langmap. Run the following command to see how that argument works:
ctags --langmap=php:+.inc.foo.bar --list-maps=php
So in your case, you would probably use something like this to generate your TAGS file:
ctags -e -R --langmap=php:+.inc
Tangentially, note also the options listed when you run ctags --list-kinds=php. You can then control which of those will be used: ctags --php-kinds=-v-j --list-kinds=php

wget download and rename files that originally have no file extension

Have a wget download I'm trying to perform.
It downloads several thousand files, unless I start to restrict the file type (junk files etc). In theory restricting the file type is fine.
However there are lots of files that wget downloads without a file extension, that when manually opened with Adobe for example, are actually PDF's. These are actually the files I want.
Restricting the wget to filetype PDF does not download these files.
So far my syntax is wget -r --no-parent A.pdf www.websitehere.com
Using wget -r --no-parent www.websitehere.com brings me every file type, so in theory I have everything. But this means I have 1000's of junk files to remove, and then several hundred of the useful files of unknown file type to rename.
Any ideas on how to wget and save the files with the appropriate file extension?
Alternatively, a way restrict the wget to only files without a file extension, and then a separate batch method to determine the file type and rename appropriately?
Manually testing every file to determine the appropriate application will take a lot of time.
Appreciate any help!
wget has an --adjust-extension option, which will add the correct extensions to HTML and CSS files. Other files (like PDFs) may not work, though. See the complete documentation here.